alperugurcan commited on
Commit
7971536
·
verified ·
1 Parent(s): 13a1b97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -9,7 +9,13 @@ def analyze_face(image):
9
  image_array = np.array(image)
10
 
11
  # Perform DeepFace analysis
12
- analysis_result = DeepFace.analyze(img_path=image_array, actions=['age', 'gender', 'race', 'emotion'])
 
 
 
 
 
 
13
 
14
  # Extract results
15
  age = analysis_result['age']
@@ -33,4 +39,4 @@ iface = gr.Interface(
33
  )
34
 
35
  # Launch the Gradio app
36
- iface.launch()
 
9
  image_array = np.array(image)
10
 
11
  # Perform DeepFace analysis
12
+ analysis_results = DeepFace.analyze(img_path=image_array, actions=['age', 'gender', 'race', 'emotion'])
13
+
14
+ # Handle single and multiple faces
15
+ if isinstance(analysis_results, list):
16
+ analysis_result = analysis_results[0] # Use the first face result if multiple faces are detected
17
+ else:
18
+ analysis_result = analysis_results
19
 
20
  # Extract results
21
  age = analysis_result['age']
 
39
  )
40
 
41
  # Launch the Gradio app
42
+ iface.launch()