Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
pipeline = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion", return_all_scores=True) | |
def predict(input_text): | |
preds = pipeline(input_text) | |
pred= preds[0] | |
res = {"Sadness π": pred[0]["score"], | |
"Joy π": pred[1]["score"], | |
"Love π": pred[2]["score"], | |
"Anger π ": pred[3]["score"], | |
"Fear π¨": pred[4]["score"], | |
"Surprise π²": pred[5]["score"], | |
} | |
return res | |
iface = gr.Interface(fn = predict, | |
inputs = "text", | |
outputs = gr.outputs.Label(num_top_classes=None, type="auto", label=None), | |
title = 'Sentiment Analysis') | |
iface.launch() | |