Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -535,7 +535,7 @@ def detect_logos(pil_image):
|
|
| 535 |
'Logo Positions': positions_str}
|
| 536 |
|
| 537 |
|
| 538 |
-
def analyze_face_features(image
|
| 539 |
#GDPR -- exclude gender and race inference
|
| 540 |
|
| 541 |
# BGR format for deepface
|
|
@@ -563,15 +563,8 @@ def analyze_face_features(image, confidence_threshold=0.3):
|
|
| 563 |
"surprise": 0,
|
| 564 |
"neutral": 0}
|
| 565 |
|
| 566 |
-
# Filter out low confidence detections
|
| 567 |
-
filtered_results = []
|
| 568 |
-
for face in results:
|
| 569 |
-
# Check for face_confidence key specifically based on your output
|
| 570 |
-
if 'face_confidence' in face and face['face_confidence'] >= confidence_threshold:
|
| 571 |
-
filtered_results.append(face)
|
| 572 |
-
|
| 573 |
# If no faces meet confidence threshold, return zeros
|
| 574 |
-
if not
|
| 575 |
return {
|
| 576 |
"angry": 0,
|
| 577 |
"disgust": 0,
|
|
@@ -593,14 +586,14 @@ def analyze_face_features(image, confidence_threshold=0.3):
|
|
| 593 |
}
|
| 594 |
|
| 595 |
# process faces
|
| 596 |
-
for face in
|
| 597 |
for emotion, value in face['emotion'].items():
|
| 598 |
emotion_lower = emotion.lower()
|
| 599 |
if emotion_lower in emotions_sum:
|
| 600 |
emotions_sum[emotion_lower] += value
|
| 601 |
|
| 602 |
# average emtions
|
| 603 |
-
num_faces = len(
|
| 604 |
avg_emotions = {emotion: round(value / num_faces, 2) for emotion, value in emotions_sum.items()}
|
| 605 |
|
| 606 |
result = {
|
|
|
|
| 535 |
'Logo Positions': positions_str}
|
| 536 |
|
| 537 |
|
| 538 |
+
def analyze_face_features(image):
|
| 539 |
#GDPR -- exclude gender and race inference
|
| 540 |
|
| 541 |
# BGR format for deepface
|
|
|
|
| 563 |
"surprise": 0,
|
| 564 |
"neutral": 0}
|
| 565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
# If no faces meet confidence threshold, return zeros
|
| 567 |
+
if not results:
|
| 568 |
return {
|
| 569 |
"angry": 0,
|
| 570 |
"disgust": 0,
|
|
|
|
| 586 |
}
|
| 587 |
|
| 588 |
# process faces
|
| 589 |
+
for face in results:
|
| 590 |
for emotion, value in face['emotion'].items():
|
| 591 |
emotion_lower = emotion.lower()
|
| 592 |
if emotion_lower in emotions_sum:
|
| 593 |
emotions_sum[emotion_lower] += value
|
| 594 |
|
| 595 |
# average emtions
|
| 596 |
+
num_faces = len(results)
|
| 597 |
avg_emotions = {emotion: round(value / num_faces, 2) for emotion, value in emotions_sum.items()}
|
| 598 |
|
| 599 |
result = {
|