Spaces:
Sleeping
Sleeping
File size: 620 Bytes
438c749 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from deepface import DeepFace
import os
from collections import Counter
def analyze_emotions(frames_folder="frames"):
emotions = []
for file in sorted(os.listdir(frames_folder)):
img_path = os.path.join(frames_folder, file)
try:
result = DeepFace.analyze(
img_path,
actions=['emotion'],
enforce_detection=False
)
dominant = result[0]['dominant_emotion']
emotions.append(dominant)
except:
continue
emotion_counts = Counter(emotions)
return emotion_counts, emotions |