File size: 762 Bytes
8e2c54a
0f442d1
8e2c54a
222e0a9
 
8e2c54a
222e0a9
 
0f442d1
222e0a9
 
 
8e2c54a
 
 
222e0a9
 
8e2c54a
222e0a9
 
8e2c54a
0f442d1
8e2c54a
 
 
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
import gradio as gr
from transformers import pipeline

# Load the emotion detection pipeline
emotion_pipeline = pipeline("text-classification", model="bhadresh-savani/distilbert-base-uncased-emotion")

def predict_emotion(text):
    result = emotion_pipeline(text)[0]
    label = result["label"]
    score = result["score"]

    return f"🧠 Emotion: {label.upper()} ({score:.2f})"

# Gradio Interface
demo = gr.Interface(
    fn=predict_emotion,
    inputs=gr.Textbox(lines=3, placeholder="Type something emotional..."),
    outputs="text",
    title="🎭 LM Studios Emotion Detector",
    description="Now with real emotional awareness: detects joy, anger, sadness, fear, love, and surprise.",
    theme="default",
    flagging_mode="never"
)

demo.launch()