From f1734b23675f397fa7e89334cbaeb8353ba24b4b Mon Sep 17 00:00:00 2001 From: galthran-wq Date: Tue, 11 Feb 2025 20:05:23 +0000 Subject: [PATCH] linting --- deepface/DeepFace.py | 3 ++- deepface/models/FacialRecognition.py | 3 +-- deepface/models/facial_recognition/Dlib.py | 3 +-- deepface/models/facial_recognition/SFace.py | 3 +-- deepface/models/facial_recognition/VGGFace.py | 2 +- deepface/modules/representation.py | 9 ++++++--- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 9f3ff1e..02dcf3f 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -387,7 +387,8 @@ def represent( Represent facial images as multi-dimensional vector embeddings. 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 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, diff --git a/deepface/models/FacialRecognition.py b/deepface/models/FacialRecognition.py index ae9958e..410a033 100644 --- a/deepface/models/FacialRecognition.py +++ b/deepface/models/FacialRecognition.py @@ -31,5 +31,4 @@ class FacialRecognition(ABC): embeddings = self.model(img, training=False).numpy() if embeddings.shape[0] == 1: return embeddings[0].tolist() - else: - return embeddings.tolist() + return embeddings.tolist() diff --git a/deepface/models/facial_recognition/Dlib.py b/deepface/models/facial_recognition/Dlib.py index cb95f08..a2e5ca6 100644 --- a/deepface/models/facial_recognition/Dlib.py +++ b/deepface/models/facial_recognition/Dlib.py @@ -53,8 +53,7 @@ class DlibClient(FacialRecognition): embeddings = [np.array(embedding).tolist() for embedding in embeddings] if len(embeddings) == 1: return embeddings[0] - else: - return embeddings + return embeddings class DlibResNet: diff --git a/deepface/models/facial_recognition/SFace.py b/deepface/models/facial_recognition/SFace.py index 53dfb86..eeebbe3 100644 --- a/deepface/models/facial_recognition/SFace.py +++ b/deepface/models/facial_recognition/SFace.py @@ -47,8 +47,7 @@ class SFaceClient(FacialRecognition): if embeddings.shape[0] == 1: return embeddings[0].tolist() - else: - return embeddings.tolist() + return embeddings.tolist() def load_model( diff --git a/deepface/models/facial_recognition/VGGFace.py b/deepface/models/facial_recognition/VGGFace.py index a3ea2e3..bffd0d6 100644 --- a/deepface/models/facial_recognition/VGGFace.py +++ b/deepface/models/facial_recognition/VGGFace.py @@ -71,7 +71,7 @@ class VggFaceClient(FacialRecognition): # instead we are now calculating it with traditional way not with keras backend embedding = super().forward(img) if ( - isinstance(embedding, list) and + isinstance(embedding, list) and isinstance(embedding[0], list) ): embedding = verification.l2_normalize(embedding, axis=1) diff --git a/deepface/modules/representation.py b/deepface/modules/representation.py index d36f5bc..56eaef2 100644 --- a/deepface/modules/representation.py +++ b/deepface/modules/representation.py @@ -25,8 +25,10 @@ def represent( Represent facial images as multi-dimensional vector embeddings. Args: - 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, + 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, @@ -84,7 +86,8 @@ def represent( 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 if detector_backend != "skip": img_objs = detection.extract_faces(