Spaces:
Running
Running
File size: 616 Bytes
b32d447 76745fa b32d447 76745fa b32d447 76745fa b32d447 76745fa b32d447 76745fa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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()
|