diff --git a/ammico/faces.py b/ammico/faces.py index 1e69d3b..30b5b17 100644 --- a/ammico/faces.py +++ b/ammico/faces.py @@ -268,11 +268,13 @@ class EmotionDetector(AnalysisMethod): # one dictionary per face that is detected in the image # since we are only passing a subregion of the image # that contains one face, the list will only contain one dict - fresult["result"] = DeepFace.analyze( - img_path=face, - actions=self.actions, - silent=True, - ) + print("actions are:", self.actions) + if self.actions != []: + fresult["result"] = DeepFace.analyze( + img_path=face, + actions=self.actions, + silent=True, + ) return fresult def facial_expression_analysis(self) -> dict: diff --git a/ammico/notebooks/DemoNotebook_ammico.ipynb b/ammico/notebooks/DemoNotebook_ammico.ipynb index 69b8ee3..e2d375e 100644 --- a/ammico/notebooks/DemoNotebook_ammico.ipynb +++ b/ammico/notebooks/DemoNotebook_ammico.ipynb @@ -257,8 +257,17 @@ "metadata": {}, "outputs": [], "source": [ + "# set the thresholds for the emotion detection\n", + "emotion_threshold = 50 # this is the default value for the detection confidence\n", + "# the lowest possible value is 0\n", + "# the highest possible value is 100\n", + "race_threshold = 50\n", + "gender_threshold = 50\n", "for num, key in tqdm(enumerate(image_dict.keys()), total=len(image_dict)): # loop through all images\n", - " image_dict[key] = ammico.EmotionDetector(image_dict[key]).analyse_image() # analyse image with EmotionDetector and update dict\n", + " image_dict[key] = ammico.EmotionDetector(image_dict[key],\n", + " emotion_threshold=emotion_threshold,\n", + " race_threshold=race_threshold,\n", + " gender_threshold=gender_threshold).analyse_image() # analyse image with EmotionDetector and update dict\n", " if num % dump_every == 0 or num == len(image_dict) - 1: # save results every dump_every to dump_file\n", " image_df = ammico.get_dataframe(image_dict)\n", " image_df.to_csv(dump_file)" @@ -1411,7 +1420,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.9" } }, "nbformat": 4,