mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 03:55:21 +00:00
comments
This commit is contained in:
parent
add4c73944
commit
93b8af100b
@ -96,12 +96,8 @@ def test_different_detectors():
|
|||||||
# "dlib",
|
# "dlib",
|
||||||
])
|
])
|
||||||
def test_batch_extract_faces(detector_backend):
|
def test_batch_extract_faces(detector_backend):
|
||||||
detector_backend_to_rtol = {
|
# Relative tolerance for comparing floating-point values
|
||||||
"opencv": 0.1,
|
rtol = 0.03
|
||||||
"mtcnn": 0.2,
|
|
||||||
"yolov11s": 0.03,
|
|
||||||
}
|
|
||||||
rtol = detector_backend_to_rtol.get(detector_backend, 0.01)
|
|
||||||
img_paths = [
|
img_paths = [
|
||||||
"dataset/img2.jpg",
|
"dataset/img2.jpg",
|
||||||
"dataset/img3.jpg",
|
"dataset/img3.jpg",
|
||||||
@ -154,15 +150,20 @@ def test_batch_extract_faces(detector_backend):
|
|||||||
img_obj_individual["facial_area"][key],
|
img_obj_individual["facial_area"][key],
|
||||||
img_obj_batch["facial_area"][key]
|
img_obj_batch["facial_area"][key]
|
||||||
):
|
):
|
||||||
|
# Ensure the difference between individual and batch values
|
||||||
|
# is within rtol% of the individual value
|
||||||
assert abs(ind_val - batch_val) <= rtol * ind_val
|
assert abs(ind_val - batch_val) <= rtol * ind_val
|
||||||
elif (
|
elif (
|
||||||
isinstance(img_obj_individual["facial_area"][key], int) or
|
isinstance(img_obj_individual["facial_area"][key], int) or
|
||||||
isinstance(img_obj_individual["facial_area"][key], float)
|
isinstance(img_obj_individual["facial_area"][key], float)
|
||||||
):
|
):
|
||||||
|
# Ensure the difference between individual and batch values
|
||||||
|
# is within rtol% of the individual value
|
||||||
assert abs(
|
assert abs(
|
||||||
img_obj_individual["facial_area"][key] -
|
img_obj_individual["facial_area"][key] -
|
||||||
img_obj_batch["facial_area"][key]
|
img_obj_batch["facial_area"][key]
|
||||||
) <= rtol * img_obj_individual["facial_area"][key]
|
) <= rtol * img_obj_individual["facial_area"][key]
|
||||||
|
# Ensure the confidence difference is within rtol% of the individual confidence
|
||||||
assert abs(
|
assert abs(
|
||||||
img_obj_individual["confidence"] -
|
img_obj_individual["confidence"] -
|
||||||
img_obj_batch["confidence"]
|
img_obj_batch["confidence"]
|
||||||
@ -175,7 +176,7 @@ def test_batch_extract_faces(detector_backend):
|
|||||||
"mtcnn",
|
"mtcnn",
|
||||||
"retinaface",
|
"retinaface",
|
||||||
"yunet",
|
"yunet",
|
||||||
"centerface",
|
# "centerface",
|
||||||
# optional
|
# optional
|
||||||
# "yolov11s",
|
# "yolov11s",
|
||||||
# "mediapipe",
|
# "mediapipe",
|
||||||
@ -217,8 +218,8 @@ def test_batch_extract_faces_with_nparray(detector_backend):
|
|||||||
|
|
||||||
# Check that the batch extraction returned the expected number of face lists
|
# Check that the batch extraction returned the expected number of face lists
|
||||||
assert len(imgs_objs_batch) == 4
|
assert len(imgs_objs_batch) == 4
|
||||||
for img_objs_batch, expected_num_faces in zip(imgs_objs_batch, expected_num_faces):
|
for img_objs_batch, img_expected_num_faces in zip(imgs_objs_batch, expected_num_faces):
|
||||||
assert len(img_objs_batch) == expected_num_faces
|
assert len(img_objs_batch) == img_expected_num_faces
|
||||||
|
|
||||||
# extract faces in batch of paths
|
# extract faces in batch of paths
|
||||||
imgs_objs_batch_paths = DeepFace.extract_faces(
|
imgs_objs_batch_paths = DeepFace.extract_faces(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user