Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122import gradio as grfrom transformers import pipeline
# Load the modelmodel_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 interfaceinterface = 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 appinterface.launch()app.pyAdded+22