shaktibiplab commited on
Commit
c0d9a98
·
verified ·
1 Parent(s): 2798965

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -31,6 +31,11 @@ def analyze_face(image_path):
31
  jpg_path = convert_to_jpg(image_path)
32
  handwriting_result = perform_handwriting_recognition_easyocr(jpg_path)
33
  analysis = DeepFace.analyze(img_path=jpg_path, actions=["age", "gender", "emotion", "race"], enforce_detection=False)
 
 
 
 
 
34
  gender_scores = analysis.get("gender", {"Man": 0, "Woman": 0})
35
  predicted_gender = "Male" if gender_scores.get("Man", 0) > gender_scores.get("Woman", 0) else "Female"
36
 
 
31
  jpg_path = convert_to_jpg(image_path)
32
  handwriting_result = perform_handwriting_recognition_easyocr(jpg_path)
33
  analysis = DeepFace.analyze(img_path=jpg_path, actions=["age", "gender", "emotion", "race"], enforce_detection=False)
34
+
35
+ # Handle multiple faces in the image
36
+ if isinstance(analysis, list):
37
+ analysis = analysis[0] # Use the first detected face
38
+
39
  gender_scores = analysis.get("gender", {"Man": 0, "Woman": 0})
40
  predicted_gender = "Male" if gender_scores.get("Man", 0) > gender_scores.get("Woman", 0) else "Female"
41