diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 3abe6db..eeacbe7 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -2,7 +2,7 @@ import os import warnings import logging -from typing import Any, Dict, IO, List, Union, Optional +from typing import Any, Dict, IO, List, Union, Optional, Sequence # this has to be set before importing tensorflow os.environ["TF_USE_LEGACY_KERAS"] = "1" @@ -510,7 +510,7 @@ def stream( def extract_faces( - img_path: Union[str, np.ndarray, IO[bytes]], + img_path: Union[str, np.ndarray, IO[bytes], Sequence[Union[str, np.ndarray, IO[bytes]]]], detector_backend: str = "opencv", enforce_detection: bool = True, align: bool = True, @@ -521,12 +521,12 @@ def extract_faces( anti_spoofing: bool = False, ) -> List[Dict[str, Any]]: """ - Extract faces from a given image + Extract faces from a given image or sequence of images. Args: - img_path (str or np.ndarray or IO[bytes]): Path to the first image. Accepts exact image path - as a string, numpy array (BGR), a file object that supports at least `.read` and is - opened in binary mode, or base64 encoded images. + img_path (Union[str, np.ndarray, IO[bytes], Sequence[Union[str, np.ndarray, IO[bytes]]]]): + Path(s) to the image(s). Accepts a string path, a numpy array (BGR), a file object + that supports at least `.read` and is opened in binary mode, or base64 encoded images. detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', diff --git a/deepface/modules/detection.py b/deepface/modules/detection.py index aefd3ec..21d09f5 100644 --- a/deepface/modules/detection.py +++ b/deepface/modules/detection.py @@ -1,5 +1,5 @@ # built-in dependencies -from typing import Any, Dict, IO, List, Tuple, Union, Optional +from typing import Any, Dict, IO, List, Tuple, Union, Optional, Sequence # 3rd part dependencies from heapq import nlargest @@ -19,7 +19,7 @@ logger = Logger() def extract_faces( - img_path: Union[List[Union[str, np.ndarray, IO[bytes]]], str, np.ndarray, IO[bytes]], + img_path: Union[Sequence[Union[str, np.ndarray, IO[bytes]]], str, np.ndarray, IO[bytes]], detector_backend: str = "opencv", enforce_detection: bool = True, align: bool = True,