deepFace batch detection; typing

This commit is contained in:
galthran-wq 2025-02-12 10:04:20 +00:00
parent f4d18a70c0
commit 0ad7c57abf
2 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@
import os import os
import warnings import warnings
import logging 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 # this has to be set before importing tensorflow
os.environ["TF_USE_LEGACY_KERAS"] = "1" os.environ["TF_USE_LEGACY_KERAS"] = "1"
@ -510,7 +510,7 @@ def stream(
def extract_faces( 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", detector_backend: str = "opencv",
enforce_detection: bool = True, enforce_detection: bool = True,
align: bool = True, align: bool = True,
@ -521,12 +521,12 @@ def extract_faces(
anti_spoofing: bool = False, anti_spoofing: bool = False,
) -> List[Dict[str, Any]]: ) -> List[Dict[str, Any]]:
""" """
Extract faces from a given image Extract faces from a given image or sequence of images.
Args: Args:
img_path (str or np.ndarray or IO[bytes]): Path to the first image. Accepts exact image path img_path (Union[str, np.ndarray, IO[bytes], Sequence[Union[str, np.ndarray, IO[bytes]]]]):
as a string, numpy array (BGR), a file object that supports at least `.read` and is Path(s) to the image(s). Accepts a string path, a numpy array (BGR), a file object
opened in binary mode, or base64 encoded images. that supports at least `.read` and is opened in binary mode, or base64 encoded images.
detector_backend (string): face detector backend. Options: 'opencv', 'retinaface', detector_backend (string): face detector backend. Options: 'opencv', 'retinaface',
'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m', 'mtcnn', 'ssd', 'dlib', 'mediapipe', 'yolov8', 'yolov11n', 'yolov11s', 'yolov11m',

View File

@ -1,5 +1,5 @@
# built-in dependencies # 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 # 3rd part dependencies
from heapq import nlargest from heapq import nlargest
@ -19,7 +19,7 @@ logger = Logger()
def extract_faces( 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", detector_backend: str = "opencv",
enforce_detection: bool = True, enforce_detection: bool = True,
align: bool = True, align: bool = True,