mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
test numpy array batched input
This commit is contained in:
parent
27dea80248
commit
526ab1baf7
@ -157,6 +157,56 @@ def test_batch_extract_faces(detector_backend):
|
|||||||
) <= rtol * img_obj_individual["confidence"]
|
) <= rtol * img_obj_individual["confidence"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("detector_backend", [
|
||||||
|
"opencv",
|
||||||
|
"ssd",
|
||||||
|
"mtcnn",
|
||||||
|
"retinaface",
|
||||||
|
"yunet",
|
||||||
|
"centerface",
|
||||||
|
# optional
|
||||||
|
# "yolov11s",
|
||||||
|
# "mediapipe",
|
||||||
|
# "dlib",
|
||||||
|
])
|
||||||
|
def test_batch_extract_faces_with_nparray(detector_backend):
|
||||||
|
img_paths = [
|
||||||
|
"dataset/img2.jpg",
|
||||||
|
"dataset/img3.jpg",
|
||||||
|
"dataset/img11.jpg",
|
||||||
|
"dataset/couple.jpg"
|
||||||
|
]
|
||||||
|
imgs = [
|
||||||
|
cv2.resize(image_utils.load_image(img_path)[0], (1920, 1080))
|
||||||
|
for img_path in img_paths
|
||||||
|
]
|
||||||
|
|
||||||
|
# load images as numpy arrays
|
||||||
|
imgs_batch = np.stack(imgs, axis=0)
|
||||||
|
|
||||||
|
# extract faces in batch of numpy arrays
|
||||||
|
imgs_objs_batch = DeepFace.extract_faces(
|
||||||
|
img_path=imgs_batch,
|
||||||
|
detector_backend=detector_backend,
|
||||||
|
align=True,
|
||||||
|
enforce_detection=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# extract faces in batch of paths
|
||||||
|
imgs_objs_batch_paths = DeepFace.extract_faces(
|
||||||
|
img_path=imgs,
|
||||||
|
detector_backend=detector_backend,
|
||||||
|
align=True,
|
||||||
|
enforce_detection=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# compare results
|
||||||
|
for img_objs_batch, img_objs_batch_paths in zip(imgs_objs_batch, imgs_objs_batch_paths):
|
||||||
|
assert len(img_objs_batch) == len(img_objs_batch_paths), (
|
||||||
|
"Batch and individual extraction results should have the same number of detected faces"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_backends_for_enforced_detection_with_non_facial_inputs():
|
def test_backends_for_enforced_detection_with_non_facial_inputs():
|
||||||
black_img = np.zeros([224, 224, 3])
|
black_img = np.zeros([224, 224, 3])
|
||||||
for detector in detectors:
|
for detector in detectors:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user