| | from transformers import pipeline |
| | import gradio as gr |
| |
|
| | |
| | sentiment_model = pipeline("sentiment-analysis") |
| |
|
| | |
| | def get_sentiment(text): |
| | result = sentiment_model(text)[0] |
| | sentiment = result['label'] |
| | score = result['score'] |
| | return sentiment, round(score, 2) |
| |
|
| | |
| | interface = gr.Interface( |
| | fn=get_sentiment, |
| | inputs=gr.Textbox(label="Enter the review:", placeholder="Write your review here..."), |
| | outputs=[ |
| | gr.Textbox(label="Sentiment:"), |
| | gr.Textbox(label="Score:") |
| | ], |
| | title="Sentiment Analysis Prototype", |
| | description="Enter a review and get the sentiment and confidence score." |
| | ) |
| |
|
| | |
| | interface.launch() |
| |
|