emotion-detect / app.py
Quanchan123abc's picture
Update app.py
76745fa verified
raw
history blame contribute delete
616 Bytes
import gradio as gr
from transformers import pipeline
# Load model locally (no API call)
emotion_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
def detect_emotion(text):
results = emotion_classifier(text)[0]
return {res["label"]: res["score"] for res in results}
iface = gr.Interface(fn=detect_emotion,
inputs="text",
outputs="label",
title="Emotion Detection",
description="Enter text to detect emotion using DistilRoBERTa")
iface.launch()