This commit is contained in:
galthran-wq 2025-02-11 20:05:23 +00:00
parent da03b479d8
commit f1734b2367
6 changed files with 12 additions and 11 deletions

View File

@ -387,7 +387,8 @@ def represent(
Represent facial images as multi-dimensional vector embeddings. Represent facial images as multi-dimensional vector embeddings.
Args: Args:
img_path (str, np.ndarray, IO[bytes], or Sequence[Union[str, np.ndarray, IO[bytes]]]): 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 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, mode, or a base64 encoded image. If the source image contains multiple faces,
the result will include information for each detected face. If a sequence is provided, the result will include information for each detected face. If a sequence is provided,

View File

@ -31,5 +31,4 @@ class FacialRecognition(ABC):
embeddings = self.model(img, training=False).numpy() embeddings = self.model(img, training=False).numpy()
if embeddings.shape[0] == 1: if embeddings.shape[0] == 1:
return embeddings[0].tolist() return embeddings[0].tolist()
else:
return embeddings.tolist() return embeddings.tolist()

View File

@ -53,7 +53,6 @@ class DlibClient(FacialRecognition):
embeddings = [np.array(embedding).tolist() for embedding in embeddings] embeddings = [np.array(embedding).tolist() for embedding in embeddings]
if len(embeddings) == 1: if len(embeddings) == 1:
return embeddings[0] return embeddings[0]
else:
return embeddings return embeddings

View File

@ -47,7 +47,6 @@ class SFaceClient(FacialRecognition):
if embeddings.shape[0] == 1: if embeddings.shape[0] == 1:
return embeddings[0].tolist() return embeddings[0].tolist()
else:
return embeddings.tolist() return embeddings.tolist()

View File

@ -25,8 +25,10 @@ def represent(
Represent facial images as multi-dimensional vector embeddings. Represent facial images as multi-dimensional vector embeddings.
Args: Args:
img_path (str, np.ndarray, or Sequence[Union[str, np.ndarray]]): The exact path to the image, a numpy array in BGR format, img_path (str, np.ndarray, or Sequence[Union[str, np.ndarray]]):
a base64 encoded image, or a sequence of these. If the source image contains multiple faces, 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. the result will include information for each detected face.
model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512, model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512,
@ -84,7 +86,8 @@ def represent(
for single_img_path in images: for single_img_path in images:
# --------------------------------- # ---------------------------------
# we have run pre-process in verification. so, this can be skipped if it is coming from verify. # we have run pre-process in verification.
# so, this can be skipped if it is coming from verify.
target_size = model.input_shape target_size = model.input_shape
if detector_backend != "skip": if detector_backend != "skip":
img_objs = detection.extract_faces( img_objs = detection.extract_faces(