mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 11:35:21 +00:00
get max_faces number faces from largest
This commit is contained in:
parent
c66804717c
commit
010bb2b1f0
@ -97,7 +97,17 @@ def represent(
|
||||
]
|
||||
# ---------------------------------
|
||||
|
||||
for idx, img_obj in enumerate(img_objs):
|
||||
if max_faces is not None and max_faces < len(img_objs):
|
||||
# sort as largest facial areas come first
|
||||
img_objs = sorted(
|
||||
img_objs,
|
||||
key=lambda img_obj: img_obj["facial_area"]["w"] * img_obj["facial_area"]["h"],
|
||||
reverse=True,
|
||||
)
|
||||
# discard rest of the items
|
||||
img_objs = img_objs[0:max_faces]
|
||||
|
||||
for img_obj in img_objs:
|
||||
if anti_spoofing is True and img_obj.get("is_real", True) is False:
|
||||
raise ValueError("Spoof detected in the given image.")
|
||||
img = img_obj["face"]
|
||||
@ -128,7 +138,4 @@ def represent(
|
||||
}
|
||||
)
|
||||
|
||||
if max_faces is not None and max_faces > 0 and max_faces > idx + 1:
|
||||
break
|
||||
|
||||
return resp_objs
|
||||
|
Loading…
x
Reference in New Issue
Block a user