| | |
| | """Sentment.ipynb |
| | |
| | Automatically generated by Colab. |
| | |
| | Original file is located at |
| | https://colab.research.google.com/drive/1ivaq7Q88JAMMQT4pr7ms9q6ZxAR4niVn |
| | """ |
| |
|
| | import gradio as gr |
| | from transformers import pipeline |
| |
|
| | |
| | classifier = pipeline('sentiment-analysis') |
| |
|
| | |
| | def predict_sentiment(text): |
| | results = classifier(text) |
| | return results[0]['label'], results[0]['score'] |
| |
|
| | |
| | iface = gr.Interface( |
| | fn=predict_sentiment, |
| | inputs="text", |
| | outputs=["text", "number"], |
| | title="Sentiment Analysis", |
| | description="Enter text to classify its sentiment as positive or negative." |
| | ) |
| |
|
| | |
| | iface.launch() |