From 1506a67725203c3ddfcbadc3f950a5d647c33071 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Fri, 23 Jun 2023 16:53:34 +0200 Subject: [PATCH 1/2] Revert some grammar changes. --- deepface/DeepFace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 6671df7..e1d1eac 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -234,7 +234,7 @@ def analyze( silent=False, ): """ - This function analyses 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 classify age, gender, emotion and race of the input image. @@ -733,7 +733,7 @@ def stream( source: Set this to 0 for access web cam. Otherwise, pass exact video path. - time_threshold (int): how many second analysed image will be displayed + time_threshold (int): how many second analyzed image will be displayed frame_threshold (int): how many frames required to focus on face From 1a3e86973753e84112c3d0bd7cd852d3cca1a00c Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Fri, 23 Jun 2023 17:37:19 +0200 Subject: [PATCH 2/2] Better type checking. --- deepface/DeepFace.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index e1d1eac..d38a810 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -296,17 +296,17 @@ def analyze( if isinstance(actions, str): actions = (actions,) - actions = list(actions) - - # Check if actions have been passed correctly - if not 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) + # 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})). " + f"Invalid action passed ({repr(action)})). " "Valid actions are `emotion`, `age`, `gender`, `race`." ) # ---------------------------------