Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the
|
5 |
-
|
6 |
|
7 |
-
def
|
8 |
-
result =
|
9 |
label = result["label"]
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
else:
|
14 |
-
return "β NEGATIVE π "
|
15 |
|
16 |
# Gradio Interface
|
17 |
demo = gr.Interface(
|
18 |
-
fn=
|
19 |
-
inputs=gr.Textbox(lines=3, placeholder="Type
|
20 |
outputs="text",
|
21 |
-
title="
|
22 |
-
description="Now
|
23 |
theme="default",
|
24 |
flagging_mode="never"
|
25 |
)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the emotion detection pipeline
|
5 |
+
emotion_pipeline = pipeline("text-classification", model="bhadresh-savani/distilbert-base-uncased-emotion")
|
6 |
|
7 |
+
def predict_emotion(text):
|
8 |
+
result = emotion_pipeline(text)[0]
|
9 |
label = result["label"]
|
10 |
+
score = result["score"]
|
11 |
+
|
12 |
+
return f"π§ Emotion: {label.upper()} ({score:.2f})"
|
|
|
|
|
13 |
|
14 |
# Gradio Interface
|
15 |
demo = gr.Interface(
|
16 |
+
fn=predict_emotion,
|
17 |
+
inputs=gr.Textbox(lines=3, placeholder="Type something emotional..."),
|
18 |
outputs="text",
|
19 |
+
title="π LM Studios Emotion Detector",
|
20 |
+
description="Now with real emotional awareness: detects joy, anger, sadness, fear, love, and surprise.",
|
21 |
theme="default",
|
22 |
flagging_mode="never"
|
23 |
)
|