Spaces:
Runtime error
Runtime error
File size: 930 Bytes
5c8cf8c ebf88d6 3a70449 ebf88d6 3a70449 ebf88d6 3a70449 |
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 fer import Video
import pandas as pd
def analyze_video_emotions(video_file_path, face_detector):
"""
Analyzes the emotions in a given video file and returns a dataframe of scores.
"""
input_video = Video(video_file_path)
processing_data = input_video.analyze(face_detector, display=False)
if not processing_data:
print("No faces detected in the video.")
return pd.DataFrame()
vid_df = input_video.to_pandas(processing_data)
vid_df = input_video.get_first_face(vid_df)
vid_df = input_video.get_emotions(vid_df)
emotions = ['angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral']
emotions_values = [sum(vid_df[emotion]) for emotion in emotions]
score_comparisons = pd.DataFrame({
'Human Emotions': [emotion.capitalize() for emotion in emotions],
'Emotion Value from the Video': emotions_values
})
return score_comparisons
|