diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 51cc8e2..9f3ff1e 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" @@ -373,7 +373,7 @@ def find( def represent( - img_path: Union[str, np.ndarray, IO[bytes], List[Union[str, np.ndarray]]], + img_path: Union[str, np.ndarray, IO[bytes], Sequence[Union[str, np.ndarray, IO[bytes]]]], model_name: str = "VGG-Face", enforce_detection: bool = True, detector_backend: str = "opencv", @@ -387,10 +387,10 @@ def represent( Represent facial images as multi-dimensional vector embeddings. Args: - img_path (str, np.ndarray, IO[bytes], or List[Union[str, np.ndarray]]): The exact path to the image, a numpy array + img_path (str, np.ndarray, IO[bytes], or Sequence[Union[str, np.ndarray, IO[bytes]]]): The exact path to the image, a numpy array in BGR format, a file object that supports at least `.read` and is opened in binary mode, or a base64 encoded image. If the source image contains multiple faces, - the result will include information for each detected face. If a list is provided, + the result will include information for each detected face. If a sequence is provided, each element should be a string or numpy array representing an image, and the function will process images in batch. diff --git a/deepface/modules/representation.py b/deepface/modules/representation.py index 6bdbf1b..d36f5bc 100644 --- a/deepface/modules/representation.py +++ b/deepface/modules/representation.py @@ -1,5 +1,5 @@ # built-in dependencies -from typing import Any, Dict, List, Union, Optional +from typing import Any, Dict, List, Union, Optional, Sequence, IO # 3rd party dependencies import numpy as np @@ -11,7 +11,7 @@ from deepface.models.FacialRecognition import FacialRecognition def represent( - img_path: Union[str, np.ndarray, List[Union[str, np.ndarray]]], + img_path: Union[str, IO[bytes], np.ndarray, Sequence[Union[str, np.ndarray, IO[bytes]]]], model_name: str = "VGG-Face", enforce_detection: bool = True, detector_backend: str = "opencv", @@ -25,8 +25,8 @@ def represent( Represent facial images as multi-dimensional vector embeddings. Args: - img_path (str, np.ndarray, or list): The exact path to the image, a numpy array in BGR format, - a base64 encoded image, or a list of these. If the source image contains multiple faces, + img_path (str, np.ndarray, or Sequence[Union[str, np.ndarray]]): The exact path to the image, a numpy array in BGR format, + a base64 encoded image, or a sequence of these. If the source image contains multiple faces, the result will include information for each detected face. model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512,