Unlinted changes

This commit is contained in:
Vincent STRAGIER 2023-05-23 14:47:22 +02:00
parent ce4e4f664b
commit e643f56b75
2 changed files with 21 additions and 17 deletions

View File

@ -9,5 +9,7 @@
"python.formatting.provider": "black", "python.formatting.provider": "black",
"python.formatting.blackArgs": ["--line-length=100"], "python.formatting.blackArgs": ["--line-length=100"],
"editor.fontWeight": "normal", "editor.fontWeight": "normal",
"python.analysis.extraPaths": ["./deepface"] "python.analysis.extraPaths": ["./deepface"],
"stylelint.autoFixOnSave": false,
"standard.autoFixOnSave": false
} }

View File

@ -41,7 +41,6 @@ if tf_version == 2:
def build_model(model_name): def build_model(model_name):
""" """
This function builds a deepface model This function builds a deepface model
Parameters: Parameters:
@ -96,7 +95,6 @@ def verify(
align=True, align=True,
normalization="base", normalization="base",
): ):
""" """
This function verifies an image pair is same person or different persons. In the background, This function verifies an image pair is same person or different persons. In the background,
verification function represents facial images as vectors and then calculates the similarity verification function represents facial images as vectors and then calculates the similarity
@ -119,9 +117,9 @@ def verify(
detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd, detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd,
dlib or mediapipe dlib or mediapipe
align (boolean): alignment according to the eye positions. align (boolean): alignment according to the eye positions.
normalization (string): normalize the input image before feeding to model normalization (string): normalize the input image before feeding to model
Returns: Returns:
@ -235,9 +233,8 @@ def analyze(
align=True, align=True,
silent=False, silent=False,
): ):
""" """
This function analyzes facial attributes including age, gender, emotion and race. This function analyze facial attributes including age, gender, emotion and race.
In the background, analysis function builds convolutional neural network models to In the background, analysis function builds convolutional neural network models to
classify age, gender, emotion and race of the input image. classify age, gender, emotion and race of the input image.
@ -255,7 +252,7 @@ def analyze(
detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd, detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd,
dlib or mediapipe. dlib or mediapipe.
align (boolean): alignment according to the eye positions. align (boolean): alignment according to the eye positions.
silent (boolean): disable (some) log messages silent (boolean): disable (some) log messages
@ -300,6 +297,16 @@ def analyze(
actions = (actions,) actions = (actions,)
actions = list(actions) actions = list(actions)
if not actions:
raise ValueError("`actions` must be a list of strings.")
for action in actions:
if action not in ("emotion", "age", "gender", "race"):
raise ValueError(
f"Invalid action passed ({action})). "
"Valid actions are `emotion`, `age`, `gender`, `race`."
)
# --------------------------------- # ---------------------------------
# build models # build models
models = {} models = {}
@ -398,7 +405,6 @@ def find(
normalization="base", normalization="base",
silent=False, silent=False,
): ):
""" """
This function applies verification several times and find the identities in a database This function applies verification several times and find the identities in a database
@ -422,9 +428,9 @@ def find(
detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd, detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd,
dlib or mediapipe dlib or mediapipe
align (boolean): alignment according to the eye positions. align (boolean): alignment according to the eye positions.
normalization (string): normalize the input image before feeding to model normalization (string): normalize the input image before feeding to model
silent (boolean): disable some logging and progress bars silent (boolean): disable some logging and progress bars
@ -448,7 +454,6 @@ def find(
file_name = file_name.replace("-", "_").lower() file_name = file_name.replace("-", "_").lower()
if path.exists(db_path + "/" + file_name): if path.exists(db_path + "/" + file_name):
if not silent: if not silent:
print( print(
f"WARNING: Representations for images in {db_path} folder were previously stored" f"WARNING: Representations for images in {db_path} folder were previously stored"
@ -616,7 +621,6 @@ def represent(
align=True, align=True,
normalization="base", normalization="base",
): ):
""" """
This function represents facial images as vectors. The function uses convolutional neural This function represents facial images as vectors. The function uses convolutional neural
networks models to generate vector embeddings. networks models to generate vector embeddings.
@ -710,7 +714,6 @@ def stream(
time_threshold=5, time_threshold=5,
frame_threshold=5, frame_threshold=5,
): ):
""" """
This function applies real time face recognition and facial attribute analysis This function applies real time face recognition and facial attribute analysis
@ -765,7 +768,6 @@ def extract_faces(
align=True, align=True,
grayscale=False, grayscale=False,
): ):
""" """
This function applies pre-processing stages of a face recognition pipeline This function applies pre-processing stages of a face recognition pipeline
including detection and alignment including detection and alignment
@ -830,7 +832,7 @@ def detectFace(
): ):
""" """
Deprecated function. Use extract_faces for same functionality. Deprecated function. Use extract_faces for same functionality.
This function applies pre-processing stages of a face recognition pipeline This function applies pre-processing stages of a face recognition pipeline
including detection and alignment including detection and alignment
@ -855,7 +857,7 @@ def detectFace(
Returns: Returns:
detected and aligned face as numpy array detected and aligned face as numpy array
""" """
print("⚠️ Function detectFace is deprecated. Use extract_faces instead.") print("⚠️ Function detectFace is deprecated. Use extract_faces instead.")
face_objs = extract_faces( face_objs = extract_faces(