walkermanj's picture
Update app.py
222e0a9 verified
raw
history blame contribute delete
762 Bytes
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()