File size: 580 Bytes
6e9582f c3dddf1 6e9582f 7a9d9b0 6e9582f 23703ce 7a9d9b0 2c21bdb 7a9d9b0 23703ce 6e9582f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import pipeline
classifiers = pipeline(
"text-classification",
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
)
def predict_my_sentiment(name):
prediction = classifiers(name)[0]
label = prediction['label']
score = prediction['score']
return label,score
demo = gr.Interface(
fn=predict_my_sentiment,
inputs=gr.Textbox(label="Type Your Current mindset !!!"),
outputs=[
gr.Textbox(label="Sentiment Label"),
gr.Number(label="Confidence Score")
]
)
demo.launch()
|