Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model | |
| model_name = "cirimus/modernbert-base-go-emotions" | |
| classifier = pipeline("text-classification", model=model_name, top_k=None) | |
| def classify_text(text): | |
| predictions = classifier(text) | |
| return {pred["label"]: pred["score"] for pred in predictions[0]} | |
| # Create the Gradio interface | |
| interface = gr.Interface( | |
| fn=classify_text, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter text to analyze emotions..."), | |
| outputs=gr.Label(num_top_classes=5), | |
| title="Emotion Classifier", | |
| description="Enter a sentence to see its associated emotions and confidence scores.", | |
| ) | |
| # Launch the app | |
| interface.launch() | |