Spaces:
Runtime error
Runtime error
File size: 756 Bytes
08c7df0 fef0bcc 08c7df0 fef0bcc 08c7df0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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()
|