Skip to content

Commit

Permalink
fix: added input_shape to YoloFacialRecognitionClient
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-corno-nttdata committed Dec 9, 2024
1 parent 01bf48d commit 79dedc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 4 additions & 3 deletions deepface/models/facial_recognition/Yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ class YoloModel(Enum):

class YoloFacialRecognitionClient(FacialRecognition):
def __init__(self, model: YoloModel):
super().__init__(model)
super().__init__()
self.model_name = "Yolo"
self.input_shape = None
self.input_shape = (224, 224)
self.output_shape = 512
self.model = self.build_model(model)

def build_model(self, model: YoloModel) -> Any:
"""
Expand All @@ -64,7 +65,7 @@ def build_model(self, model: YoloModel) -> Any:
return YOLO(weight_file)

def forward(self, img: np.ndarray) -> List[float]:
return self.model.embed(img)[0].tolist()
return self.model.embed(np.squeeze(img, axis=0))[0].tolist()


class YoloFacialRecognitionClientV8n(YoloFacialRecognitionClient):
Expand Down
11 changes: 5 additions & 6 deletions deepface/modules/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ def represent(
confidence = img_obj["confidence"]

# resize to expected shape of ml model
if target_size is not None:
img = preprocessing.resize_image(
img=img,
# thanks to DeepId (!)
target_size=(target_size[1], target_size[0]),
)
img = preprocessing.resize_image(
img=img,
# thanks to DeepId (!)
target_size=(target_size[1], target_size[0]),
)

# custom normalization
img = preprocessing.normalize_input(img=img, normalization=normalization)
Expand Down

0 comments on commit 79dedc0

Please sign in to comment.