Spaces:
Sleeping
Sleeping
File size: 520 Bytes
66ae87a a846a94 cd5e8c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import pipeline
sentiment_classifier = pipeline(
model="lxyuan/distilbert-base-multilingual-cased-sentiments-student",
return_all_scores=True
)
def get_sentiment(input):
s = sentiment_classifier (input)[0][0]['score']
if s < 0.2:
return 1
elif s < 0.4:
return 2
elif s < 0.6:
return 3
elif s < 0.8:
return 4
return 5
gr.close_all()
demo = gr.Interface(fn=get_sentiment, inputs="text", outputs="text")
demo.launch() |