mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 19:45:21 +00:00
expand facial area tests
This commit is contained in:
parent
c61cb6faf2
commit
20070a3f97
@ -25,6 +25,7 @@ detector_backends = [
|
|||||||
"ssd",
|
"ssd",
|
||||||
"dlib",
|
"dlib",
|
||||||
"mtcnn",
|
"mtcnn",
|
||||||
|
"fastmtcnn",
|
||||||
# "mediapipe", # crashed in mac
|
# "mediapipe", # crashed in mac
|
||||||
"retinaface",
|
"retinaface",
|
||||||
"yunet",
|
"yunet",
|
||||||
@ -56,40 +57,39 @@ for df in dfs:
|
|||||||
logger.info(df)
|
logger.info(df)
|
||||||
|
|
||||||
|
|
||||||
|
expand_areas = [0, 25]
|
||||||
|
img_paths = ["dataset/img11.jpg", "dataset/img11_reflection.jpg"]
|
||||||
|
for expand_area in expand_areas:
|
||||||
|
for img_path in img_paths:
|
||||||
|
# extract faces
|
||||||
|
for detector_backend in detector_backends:
|
||||||
|
face_objs = DeepFace.extract_faces(
|
||||||
|
img_path=img_path,
|
||||||
|
detector_backend=detector_backend,
|
||||||
|
align=True,
|
||||||
|
expand_percentage=expand_area,
|
||||||
|
)
|
||||||
|
for face_obj in face_objs:
|
||||||
|
face = face_obj["face"]
|
||||||
|
logger.info(detector_backend)
|
||||||
|
logger.info(face_obj["facial_area"])
|
||||||
|
logger.info(face_obj["confidence"])
|
||||||
|
|
||||||
# img_paths = ["dataset/img11.jpg", "dataset/img11_reflection.jpg", "dataset/couple.jpg"]
|
# we know opencv sometimes cannot find eyes
|
||||||
img_paths = ["dataset/img11.jpg"]
|
if face_obj["facial_area"]["left_eye"] is not None:
|
||||||
for img_path in img_paths:
|
assert isinstance(face_obj["facial_area"]["left_eye"], tuple)
|
||||||
# extract faces
|
assert isinstance(face_obj["facial_area"]["left_eye"][0], int)
|
||||||
for detector_backend in detector_backends:
|
assert isinstance(face_obj["facial_area"]["left_eye"][1], int)
|
||||||
face_objs = DeepFace.extract_faces(
|
|
||||||
img_path=img_path,
|
|
||||||
detector_backend=detector_backend,
|
|
||||||
align=True,
|
|
||||||
# expand_percentage=10,
|
|
||||||
# target_size=None,
|
|
||||||
)
|
|
||||||
for face_obj in face_objs:
|
|
||||||
face = face_obj["face"]
|
|
||||||
logger.info(detector_backend)
|
|
||||||
logger.info(face_obj["facial_area"])
|
|
||||||
logger.info(face_obj["confidence"])
|
|
||||||
|
|
||||||
# we know opencv sometimes cannot find eyes
|
if face_obj["facial_area"]["right_eye"] is not None:
|
||||||
if face_obj["facial_area"]["left_eye"] is not None:
|
assert isinstance(face_obj["facial_area"]["right_eye"], tuple)
|
||||||
assert isinstance(face_obj["facial_area"]["left_eye"], tuple)
|
assert isinstance(face_obj["facial_area"]["right_eye"][0], int)
|
||||||
assert isinstance(face_obj["facial_area"]["left_eye"][0], int)
|
assert isinstance(face_obj["facial_area"]["right_eye"][1], int)
|
||||||
assert isinstance(face_obj["facial_area"]["left_eye"][1], int)
|
|
||||||
|
|
||||||
if face_obj["facial_area"]["right_eye"] is not None:
|
assert isinstance(face_obj["confidence"], float)
|
||||||
assert isinstance(face_obj["facial_area"]["right_eye"], tuple)
|
assert face_obj["confidence"] <= 1
|
||||||
assert isinstance(face_obj["facial_area"]["right_eye"][0], int)
|
|
||||||
assert isinstance(face_obj["facial_area"]["right_eye"][1], int)
|
|
||||||
|
|
||||||
assert isinstance(face_obj["confidence"], float)
|
plt.imshow(face)
|
||||||
assert face_obj["confidence"] <= 1
|
plt.axis("off")
|
||||||
|
plt.show()
|
||||||
plt.imshow(face)
|
logger.info("-----------")
|
||||||
plt.axis("off")
|
|
||||||
plt.show()
|
|
||||||
logger.info("-----------")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user