Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,13 @@ def analyze_face(image):
|
|
| 9 |
image_array = np.array(image)
|
| 10 |
|
| 11 |
# Perform DeepFace analysis
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|