Spaces:
Sleeping
Sleeping
| 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() |