| import gradio as gr | |
| from transformers import pipeline | |
| sentiment = pipeline ("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
| def get_sentiment(input_text): | |
| result = sentiment(input_text) | |
| return result[0]['label'] | |
| result = get_sentiment("The movie was very bad") | |
| result | |
| iface = gr.Interface(fn = get_sentiment, inputs = "text", outputs = "text" ,title = 'Sentiment Analysis') | |
| iface.launch(inline= False, share=True) | |