jjpwong commited on
Commit
4b5b0a0
Β·
1 Parent(s): 17e0f85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
-
3
  from transformers import pipeline
4
 
5
  sentiment = pipeline("sentiment-analysis")
6
 
7
  def get_sentiment(input_text):
8
- return sentiment(input_text)
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- demo = gr.Interface(fn = get_sentiment,
11
- inputs = 'text',
12
- outputs = ['text'],
13
- title = 'Sentiment Analysis Demo (ζƒ…η·’εˆ†ζžη€Ίη―„)',
14
- description = "Analyze the sentiment based on given input (positive or negative) ζƒ…η·’εˆ†ζž"
15
- )
16
  demo.launch()
 
1
  import gradio as gr
 
2
  from transformers import pipeline
3
 
4
  sentiment = pipeline("sentiment-analysis")
5
 
6
  def get_sentiment(input_text):
7
+ result = sentiment(input_text)
8
+ labels = [item['label'] for item in result]
9
+ scores = [item['score'] for item in result]
10
+ return labels, scores
11
+
12
+ demo = gr.Interface(
13
+ fn=get_sentiment,
14
+ inputs="text",
15
+ outputs=[gr.Textbox(label="Label"), gr.Textbox(label="Score")],
16
+ title = 'Sentiment Analysis Demo (ζƒ…η·’εˆ†ζžη€Ίη―„)',
17
+ description = "Analyze the sentiment based on given input (positive or negative) ζƒ…η·’εˆ†ζž"
18
+ examples=[["I love Computational Chemistry."], ["This movie is terrible."]],
19
+ )
20
 
 
 
 
 
 
 
21
  demo.launch()