Maymonah commited on
Commit
da6523d
·
verified ·
1 Parent(s): b42562d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -2,13 +2,16 @@ import gradio as gr
2
  from transformers import pipeline
3
 
4
 
5
- def get_sentiment(review):
6
  sentiment = pipeline("sentiment-analysis")
7
- results = sentiment(review)
8
- first_sentiment = results[0]['label']
9
- return first_sentiment
 
10
 
11
- textbox = gr.Textbox(label="Type your sentiment here:", placeholder="type here ...", lines=2)
12
 
13
- interface = gr.Interface(fn=get_sentiment, inputs=textbox, outputs="text")
 
 
 
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()