Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -76,27 +76,36 @@ def process_video(input_path):
|
|
76 |
plt.pie(sizes, labels=labels, autopct='%1.1f%%', colors=sns.color_palette('pastel'))
|
77 |
plt.title("Emotion Distribution")
|
78 |
plt.savefig("emotion_distribution.jpg")
|
79 |
-
|
80 |
-
|
81 |
-
return "output_video.mp4", "emotion_distribution.jpg", major_emotion
|
82 |
|
83 |
# Gradio Web Interface
|
84 |
-
gr.
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
gr.Textbox(label="Major Emotion Detected")
|
91 |
-
],
|
92 |
-
title="Emotion Detection from Video",
|
93 |
-
description="Upload a video, and the AI will detect emotions in each frame, providing a processed video, an emotion distribution chart, and the major detected emotion.",
|
94 |
-
css="""
|
95 |
-
.gradio-container { max-width: 800px !important; margin: auto; }
|
96 |
-
.gradio-container h1 { font-size: 22px; }
|
97 |
@media screen and (max-width: 768px) {
|
98 |
.gradio-container { width: 100%; padding: 10px; }
|
99 |
.gradio-container h1 { font-size: 18px; }
|
100 |
}
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
plt.pie(sizes, labels=labels, autopct='%1.1f%%', colors=sns.color_palette('pastel'))
|
77 |
plt.title("Emotion Distribution")
|
78 |
plt.savefig("emotion_distribution.jpg")
|
79 |
+
|
80 |
+
return "output_video.mp4", plt, major_emotion
|
|
|
81 |
|
82 |
# Gradio Web Interface
|
83 |
+
with gr.Blocks(css="""
|
84 |
+
.gradio-container { max-width: 750px !important; margin: auto; background-color: #f8f9fa; padding: 20px; border-radius: 15px; }
|
85 |
+
.gradio-container h1 { font-size: 22px; text-align: center; color: #333; }
|
86 |
+
.gradio-container .gr-button { background-color: #007bff; color: white; border-radius: 10px; padding: 8px 15px; }
|
87 |
+
.gradio-container .gr-textbox { font-size: 16px; font-weight: bold; color: #007bff; }
|
88 |
+
.gradio-container .gr-file { border-radius: 10px; padding: 5px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
@media screen and (max-width: 768px) {
|
90 |
.gradio-container { width: 100%; padding: 10px; }
|
91 |
.gradio-container h1 { font-size: 18px; }
|
92 |
}
|
93 |
+
""") as demo:
|
94 |
+
gr.Markdown("# π Emotion Analysis from Video π₯")
|
95 |
+
gr.Markdown("Upload a video, and the AI will detect emotions in each frame, providing a processed video, an emotion distribution chart, and the major detected emotion.")
|
96 |
+
|
97 |
+
with gr.Row():
|
98 |
+
video_input = gr.File(label="π€ Upload Video (MP4, MOV, AVI)")
|
99 |
+
|
100 |
+
with gr.Row():
|
101 |
+
process_button = gr.Button("π Analyze")
|
102 |
+
|
103 |
+
with gr.Row():
|
104 |
+
video_output = gr.File(label="π₯ Processed Video")
|
105 |
+
emotion_chart = gr.Plot(label="π Emotion Distribution Chart")
|
106 |
+
|
107 |
+
major_emotion_output = gr.Textbox(label="π₯ Major Emotion Detected", interactive=False)
|
108 |
+
|
109 |
+
process_button.click(fn=process_video, inputs=video_input, outputs=[video_output, emotion_chart, major_emotion_output])
|
110 |
+
|
111 |
+
demo.launch()
|