deepface: [BUG]:
Before You Report a Bug, Please Confirm You Have Done The Following…
- I have updated to the latest version of the packages.
- I have searched for both existing issues and closed issues and found none that matched my issue.
DeepFace’s version
0.0.55
Python version
3.12.5
Operating System
windows 10
Dependencies
i am using chaquopy sdk to use deepface in android studio
numpy : 1.19.5 opencv : 4.5.1 deepface : 0.0.55
Reproducible example
def detect_emotion(image_path):
"""Detect emotion from the given image using DeepFace."""
print("Image Path: ", image_path)
try:
# Analyze emotions using DeepFace
analysis = DeepFace.analyze(image_path, actions=['emotion'])
# Print detailed information for debugging
print("DeepFace Analysis Results: ", analysis) # Debugging output
# Ensure the analysis result is a list
if isinstance(analysis, list) and len(analysis) > 0:
# Check the type and content of the first result
first_result = analysis[0]
print("Type of first result:", type(first_result))
print("Content of first result:", first_result)
if isinstance(first_result, dict):
# Extract emotions
emotions = first_result.get('emotions', {})
print("Type of emotions:", type(emotions))
print("Content of emotions:", emotions)
if isinstance(emotions, dict):
# Find the dominant emotion
dominant_emotion = max(emotions, key=emotions.get, default='unknown')
return dominant_emotion
else:
print("Emotions data is not a dictionary.")
else:
print("First result is not a dictionary.")
else:
print("Analysis result is not in the expected format.")
return None
except Exception as e:
print(f"Error in DeepFace emotion detection: {e}")
return None
Relevant Log Output
Image Path: /data/user/0/com.example.detectionpython/cache/temp_image_resized.png Error in DeepFace emotion detection: list indices must be integers or slices, not str
Expected Result
return dom emotion
What happened instead?
None value
Additional Info
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (9 by maintainers)
try to upgrade your numpy to