Skip to content

Commit

Permalink
update thresholds in notebook and empty actions list (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
iulusoy authored Jun 17, 2024
1 parent b3ba545 commit 8db4a39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 7 additions & 5 deletions ammico/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ def analyze_single_face(self, face: np.ndarray) -> dict:
# 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:
Expand Down
13 changes: 11 additions & 2 deletions ammico/notebooks/DemoNotebook_ammico.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -1411,7 +1420,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8db4a39

Please sign in to comment.