mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
Merge pull request #757 from Vincent-Stragier/analyze_raise_on_empty_actions
Raise error on empty or erroneous `actions` parameter in `analyze()` closes #729
This commit is contained in:
commit
77b57f66af
@ -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
|
||||||
@ -235,7 +233,6 @@ def analyze(
|
|||||||
align=True,
|
align=True,
|
||||||
silent=False,
|
silent=False,
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This function analyzes facial attributes including age, gender, emotion and race.
|
This function analyzes 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
|
||||||
@ -299,7 +296,19 @@ def analyze(
|
|||||||
if isinstance(actions, str):
|
if isinstance(actions, str):
|
||||||
actions = (actions,)
|
actions = (actions,)
|
||||||
|
|
||||||
|
# check if actions is not an iterable or empty.
|
||||||
|
if not hasattr(actions, "__getitem__") or not actions:
|
||||||
|
raise ValueError("`actions` must be a list of strings.")
|
||||||
|
|
||||||
actions = list(actions)
|
actions = list(actions)
|
||||||
|
|
||||||
|
# For each action, check if it is valid
|
||||||
|
for action in actions:
|
||||||
|
if action not in ("emotion", "age", "gender", "race"):
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid action passed ({repr(action)})). "
|
||||||
|
"Valid actions are `emotion`, `age`, `gender`, `race`."
|
||||||
|
)
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# build models
|
# build models
|
||||||
models = {}
|
models = {}
|
||||||
@ -398,7 +407,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
|
||||||
|
|
||||||
@ -448,7 +456,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 +623,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 +716,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 +770,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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user