sandeepmajumdar commited on
Commit
13665c5
·
1 Parent(s): cd57a03
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ def convert(Sentence):
5
+ model = pipeline('sentiment-analysis')
6
+ result = model(Sentence)
7
+ return result[0]['label'], round(result[0]['score']*100, 2)
8
+
9
+ with gr.Blocks() as bls:
10
+ gr.Markdown("Here is a Sentiment Analysis app")
11
+ with gr.Row():
12
+ inp = gr.Textbox(label="Type your sentence here and click Run", placeholder='Example: I love to eat')
13
+ out1 = gr.Textbox(label="The sentiment is:"))
14
+ out2 = gr.Number(label='Sentiment confidence % is:')
15
+ btn = gr.Button("Run")
16
+ btn.click(fn=convert, inputs=inp, outputs=[out1, out2])
17
+
18
+ bls.launch()