Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -119,6 +119,29 @@ def analyze_post(text, video):
|
|
119 |
sentiment = analyze_text(text)
|
120 |
emotion = analyze_video(video)
|
121 |
return f"π Sentiment: {sentiment}\nπ₯ Emotion: {emotion}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
interface = gr.Interface(
|
124 |
fn=analyze_post,
|
|
|
119 |
sentiment = analyze_text(text)
|
120 |
emotion = analyze_video(video)
|
121 |
return f"π Sentiment: {sentiment}\nπ₯ Emotion: {emotion}"
|
122 |
+
import gradio as gr
|
123 |
+
|
124 |
+
def analyze_text(text):
|
125 |
+
from transformers import pipeline
|
126 |
+
classifier = pipeline("sentiment-analysis")
|
127 |
+
return classifier(text)[0]['label']
|
128 |
+
|
129 |
+
def process_all(text_input, video_input):
|
130 |
+
text_result = analyze_text(text_input)
|
131 |
+
video_result = analyze_video_emotion(video_input)
|
132 |
+
return f"Text Sentiment: {text_result}\nFacial Emotion: {video_result}"
|
133 |
+
|
134 |
+
gr.Interface(
|
135 |
+
fn=process_all,
|
136 |
+
inputs=[
|
137 |
+
gr.Textbox(label="Enter Social Media Text"),
|
138 |
+
gr.Video(label="Upload a Video Clip")
|
139 |
+
],
|
140 |
+
outputs="text",
|
141 |
+
title="Emotion & Sentiment Decoder",
|
142 |
+
description="Analyzes social media text & facial expressions from video."
|
143 |
+
).launch()
|
144 |
+
|
145 |
|
146 |
interface = gr.Interface(
|
147 |
fn=analyze_post,
|