mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 11:35:21 +00:00
change interface in a special case
This commit is contained in:
parent
991566ffb1
commit
70b61a7f4f
@ -44,12 +44,12 @@ class CenterFaceClient(Detector):
|
||||
Returns:
|
||||
results (Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]): A list or a list of lists of FacialAreaRegion objects
|
||||
"""
|
||||
if isinstance(img, np.ndarray):
|
||||
return self._process_single_image(img)
|
||||
elif isinstance(img, list):
|
||||
return [self._process_single_image(single_img) for single_img in img]
|
||||
else:
|
||||
raise ValueError("Input must be a numpy array or a list of numpy arrays.")
|
||||
if not isinstance(img, list):
|
||||
img = [img]
|
||||
results = [self._process_single_image(single_img) for single_img in img]
|
||||
if len(results) == 1:
|
||||
return results[0]
|
||||
return results
|
||||
|
||||
def _process_single_image(self, single_img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
"""
|
||||
|
@ -57,14 +57,14 @@ class DlibClient(Detector):
|
||||
Returns:
|
||||
results (Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]): A list or a list of lists of FacialAreaRegion objects
|
||||
"""
|
||||
if isinstance(img, np.ndarray):
|
||||
return self._detect_faces_in_single_image(img)
|
||||
elif isinstance(img, list):
|
||||
return [self._detect_faces_in_single_image(single_img) for single_img in img]
|
||||
else:
|
||||
raise ValueError("Input must be a numpy array or a list of numpy arrays.")
|
||||
if not isinstance(img, list):
|
||||
img = [img]
|
||||
results = [self._process_single_image(single_img) for single_img in img]
|
||||
if len(results) == 1:
|
||||
return results[0]
|
||||
return results
|
||||
|
||||
def _detect_faces_in_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
def _process_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
"""
|
||||
Helper function to detect faces in a single image.
|
||||
|
||||
|
@ -27,12 +27,12 @@ class FastMtCnnClient(Detector):
|
||||
Returns:
|
||||
results (Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]): A list or a list of lists of FacialAreaRegion objects
|
||||
"""
|
||||
if isinstance(img, np.ndarray):
|
||||
return self._process_single_image(img)
|
||||
elif isinstance(img, list):
|
||||
return [self._process_single_image(single_img) for single_img in img]
|
||||
else:
|
||||
raise ValueError("Input must be a numpy array or a list of numpy arrays.")
|
||||
if not isinstance(img, list):
|
||||
img = [img]
|
||||
results = [self._process_single_image(single_img) for single_img in img]
|
||||
if len(results) == 1:
|
||||
return results[0]
|
||||
return results
|
||||
|
||||
def _process_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
"""
|
||||
|
@ -53,12 +53,12 @@ class MediaPipeClient(Detector):
|
||||
Returns:
|
||||
results (Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]): A list or a list of lists of FacialAreaRegion objects
|
||||
"""
|
||||
if isinstance(img, np.ndarray):
|
||||
return self._process_single_image(img)
|
||||
elif isinstance(img, list):
|
||||
return [self._process_single_image(single_img) for single_img in img]
|
||||
else:
|
||||
raise ValueError("Input must be a numpy array or a list of numpy arrays.")
|
||||
if not isinstance(img, list):
|
||||
img = [img]
|
||||
results = [self._process_single_image(single_img) for single_img in img]
|
||||
if len(results) == 1:
|
||||
return results[0]
|
||||
return results
|
||||
|
||||
def _process_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
"""
|
||||
|
@ -67,12 +67,12 @@ class YuNetClient(Detector):
|
||||
Returns:
|
||||
results (Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]): A list or a list of lists of FacialAreaRegion objects
|
||||
"""
|
||||
if isinstance(img, np.ndarray):
|
||||
return self._process_single_image(img)
|
||||
elif isinstance(img, list):
|
||||
return [self._process_single_image(single_img) for single_img in img]
|
||||
else:
|
||||
raise ValueError("Input must be a numpy array or a list of numpy arrays.")
|
||||
if not isinstance(img, list):
|
||||
img = [img]
|
||||
results = [self._process_single_image(single_img) for single_img in img]
|
||||
if len(results) == 1:
|
||||
return results[0]
|
||||
return results
|
||||
|
||||
def _process_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user