From 737ee793dcb7c204dc62c2a8e6de5cb7f20dc01d Mon Sep 17 00:00:00 2001 From: galthran-wq Date: Wed, 12 Feb 2025 15:47:39 +0000 Subject: [PATCH] chagne detector interface --- deepface/models/Detector.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/deepface/models/Detector.py b/deepface/models/Detector.py index 004f0d3..70675cd 100644 --- a/deepface/models/Detector.py +++ b/deepface/models/Detector.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Optional +from typing import List, Tuple, Optional, Union from abc import ABC, abstractmethod from dataclasses import dataclass import numpy as np @@ -9,15 +9,19 @@ import numpy as np # pylint: disable=unnecessary-pass, too-few-public-methods, too-many-instance-attributes class Detector(ABC): @abstractmethod - def detect_faces(self, img: np.ndarray) -> List["FacialAreaRegion"]: + def detect_faces( + self, + imgs: Union[np.ndarray, List[np.ndarray]] + ) -> Union[List["FacialAreaRegion"], List[List["FacialAreaRegion"]]]: """ - Interface for detect and align face + Interface for detect and align faces in a batch of images Args: - img (np.ndarray): pre-loaded image as numpy array + imgs (Union[np.ndarray, List[np.ndarray]]): pre-loaded image as numpy array or a list of those Returns: - results (List[FacialAreaRegion]): A list of FacialAreaRegion objects + results (Union[List[List[FacialAreaRegion]], List[FacialAreaRegion]]): + A list or a list of lists of FacialAreaRegion objects where each object contains: - facial_area (FacialAreaRegion): The facial area region represented