Merge branch 'analyze_raise_on_empty_actions' into YOLOv8

This commit is contained in:
Vincent STRAGIER 2023-06-09 13:51:30 +02:00
commit 052abd26c7

View File

@ -237,7 +237,7 @@ def analyze(
):
"""
This function analyzes facial attributes including age, gender, emotion and race.
This function analyses facial attributes including age, gender, emotion and race.
In the background, analysis function builds convolutional neural network models to
classify age, gender, emotion and race of the input image.
@ -300,6 +300,18 @@ def analyze(
actions = (actions,)
actions = list(actions)
# Check if actions have been passed correctly
if not actions:
raise ValueError("`actions` must be a list of strings.")
# 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 ({action})). "
"Valid actions are `emotion`, `age`, `gender`, `race`."
)
# ---------------------------------
# build models
models = {}
@ -728,7 +740,7 @@ def stream(
source: Set this to 0 for access web cam. Otherwise, pass exact video path.
time_threshold (int): how many second analyzed image will be displayed
time_threshold (int): how many second analysed image will be displayed
frame_threshold (int): how many frames required to focus on face