Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,16 @@ import gradio as gr
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
|
| 5 |
-
def get_sentiment(
|
| 6 |
sentiment = pipeline("sentiment-analysis")
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
textbox = gr.Textbox(label="Type your sentiment here:", placeholder="type here ...", lines=2)
|
| 12 |
|
| 13 |
-
interface = gr.Interface(fn=get_sentiment, inputs=
|
|
|
|
|
|
|
|
|
|
| 14 |
interface.launch()
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
|
| 5 |
+
def get_sentiment(text):
|
| 6 |
sentiment = pipeline("sentiment-analysis")
|
| 7 |
+
result = sentiment_pipeline(text)[0]
|
| 8 |
+
sentiment = result['label']
|
| 9 |
+
score = result['score']
|
| 10 |
+
return f"Sentiment: {sentiment}", f"Confidence: {score:.4f}"
|
| 11 |
|
|
|
|
| 12 |
|
| 13 |
+
interface = gr.Interface(fn=get_sentiment, inputs=gr.Textbox(lines=3, placeholder="Enter your review here..."), outputs=[
|
| 14 |
+
gr.Textbox(label="Predicted Sentiment"),
|
| 15 |
+
gr.Textbox(label="Confidence Score")
|
| 16 |
+
])
|
| 17 |
interface.launch()
|