Skip to content

Commit 9494d47

Browse files
committed
restoration of deprecated detect face function
1 parent cefb801 commit 9494d47

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

deepface/DeepFace.py

+46
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,49 @@ def cli() -> None:
460460
import fire
461461

462462
fire.Fire()
463+
464+
465+
# deprecated function(s)
466+
467+
468+
def detectFace(
469+
img_path: Union[str, np.ndarray],
470+
target_size: tuple = (224, 224),
471+
detector_backend: str = "opencv",
472+
enforce_detection: bool = True,
473+
align: bool = True,
474+
) -> Union[np.ndarray, None]:
475+
"""
476+
Deprecated face detection function. Use extract_faces for same functionality.
477+
478+
Args:
479+
img_path (str or np.ndarray): Path to the first image. Accepts exact image path
480+
as a string, numpy array (BGR), or base64 encoded images.
481+
482+
target_size (tuple): final shape of facial image. black pixels will be
483+
added to resize the image (default is (224, 224)).
484+
485+
detector_backend (string): face detector backend. Options: 'opencv', 'retinaface',
486+
'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8' (default is opencv).
487+
488+
enforce_detection (boolean): If no face is detected in an image, raise an exception.
489+
Set to False to avoid the exception for low-resolution images (default is True).
490+
491+
align (bool): Flag to enable face alignment (default is True).
492+
493+
Returns:
494+
img (np.ndarray): detected (and aligned) facial area image as numpy array
495+
"""
496+
logger.warn("Function detectFace is deprecated. Use extract_faces instead.")
497+
face_objs = extract_faces(
498+
img_path=img_path,
499+
target_size=target_size,
500+
detector_backend=detector_backend,
501+
enforce_detection=enforce_detection,
502+
align=align,
503+
grayscale=False,
504+
)
505+
extracted_face = None
506+
if len(face_objs) > 0:
507+
extracted_face = face_objs[0]["face"]
508+
return extracted_face

0 commit comments

Comments
 (0)