Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,19 +4,17 @@ import pandas as pd
|
|
| 4 |
import plotly.express as px
|
| 5 |
|
| 6 |
# ------------------------------
|
| 7 |
-
# Load pretrained models
|
| 8 |
# ------------------------------
|
| 9 |
text_classifier = pipeline(
|
| 10 |
"text-classification",
|
| 11 |
model="j-hartmann/emotion-english-distilroberta-base",
|
| 12 |
-
return_all_scores=True
|
| 13 |
-
device=-1 # CPU
|
| 14 |
)
|
| 15 |
|
| 16 |
audio_classifier = pipeline(
|
| 17 |
"audio-classification",
|
| 18 |
-
model="
|
| 19 |
-
device=-1 # CPU
|
| 20 |
)
|
| 21 |
|
| 22 |
# ------------------------------
|
|
@@ -30,7 +28,7 @@ EMOJI_MAP = {
|
|
| 30 |
"neutral": "π",
|
| 31 |
"sadness": "π’",
|
| 32 |
"surprise": "π²",
|
| 33 |
-
"hap": "π",
|
| 34 |
"neu": "π",
|
| 35 |
"sad": "π’",
|
| 36 |
"ang": "π‘"
|
|
@@ -108,7 +106,7 @@ def predict(text, audio, w_text, w_audio):
|
|
| 108 |
# Build Gradio interface
|
| 109 |
# ------------------------------
|
| 110 |
with gr.Blocks() as demo:
|
| 111 |
-
gr.Markdown("## π
|
| 112 |
|
| 113 |
with gr.Row():
|
| 114 |
with gr.Column():
|
|
@@ -121,6 +119,7 @@ with gr.Blocks() as demo:
|
|
| 121 |
final_label = gr.Markdown(label="Predicted Emotion")
|
| 122 |
chart_output = gr.Plot(label="Emotion Scores")
|
| 123 |
|
|
|
|
| 124 |
btn.click(fn=predict, inputs=[txt, aud, w1, w2], outputs=[final_label, chart_output])
|
| 125 |
|
| 126 |
-
demo.launch()
|
|
|
|
| 4 |
import plotly.express as px
|
| 5 |
|
| 6 |
# ------------------------------
|
| 7 |
+
# Load pretrained models
|
| 8 |
# ------------------------------
|
| 9 |
text_classifier = pipeline(
|
| 10 |
"text-classification",
|
| 11 |
model="j-hartmann/emotion-english-distilroberta-base",
|
| 12 |
+
return_all_scores=True
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
audio_classifier = pipeline(
|
| 16 |
"audio-classification",
|
| 17 |
+
model="superb/wav2vec2-base-superb-er"
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
# ------------------------------
|
|
|
|
| 28 |
"neutral": "π",
|
| 29 |
"sadness": "π’",
|
| 30 |
"surprise": "π²",
|
| 31 |
+
"hap": "π", # for audio model
|
| 32 |
"neu": "π",
|
| 33 |
"sad": "π’",
|
| 34 |
"ang": "π‘"
|
|
|
|
| 106 |
# Build Gradio interface
|
| 107 |
# ------------------------------
|
| 108 |
with gr.Blocks() as demo:
|
| 109 |
+
gr.Markdown("## π Multimodal Emotion Classification (Text + Speech)")
|
| 110 |
|
| 111 |
with gr.Row():
|
| 112 |
with gr.Column():
|
|
|
|
| 119 |
final_label = gr.Markdown(label="Predicted Emotion")
|
| 120 |
chart_output = gr.Plot(label="Emotion Scores")
|
| 121 |
|
| 122 |
+
# Button click triggers prediction
|
| 123 |
btn.click(fn=predict, inputs=[txt, aud, w1, w2], outputs=[final_label, chart_output])
|
| 124 |
|
| 125 |
+
demo.launch()
|