smart_interview_analyser / emotion_detection.py
asmithaaa's picture
Upload 40 files
438c749 verified
raw
history blame contribute delete
620 Bytes
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