mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 03:55:21 +00:00
pseudo-batching dlib
This commit is contained in:
parent
1c825e8803
commit
1d358aa15a
@ -1,5 +1,5 @@
|
|||||||
# built-in dependencies
|
# built-in dependencies
|
||||||
from typing import List
|
from typing import List, Union
|
||||||
|
|
||||||
# 3rd party dependencies
|
# 3rd party dependencies
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -47,10 +47,27 @@ class DlibClient(Detector):
|
|||||||
detector["sp"] = sp
|
detector["sp"] = sp
|
||||||
return detector
|
return detector
|
||||||
|
|
||||||
def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
def detect_faces(self, img: Union[np.ndarray, List[np.ndarray]]) -> Union[List[FacialAreaRegion], List[List[FacialAreaRegion]]]:
|
||||||
"""
|
"""
|
||||||
Detect and align face with dlib
|
Detect and align face with dlib
|
||||||
|
|
||||||
|
Args:
|
||||||
|
img (Union[np.ndarray, List[np.ndarray]]): pre-loaded image as numpy array or a list of those
|
||||||
|
|
||||||
|
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.")
|
||||||
|
|
||||||
|
def _detect_faces_in_single_image(self, img: np.ndarray) -> List[FacialAreaRegion]:
|
||||||
|
"""
|
||||||
|
Helper function to detect faces in a single image.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
img (np.ndarray): pre-loaded image as numpy array
|
img (np.ndarray): pre-loaded image as numpy array
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user