Daniel Chang commited on
Commit
8993557
·
1 Parent(s): 51c6c50

Sentiment Analsyis

Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,7 +1,11 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ classifier = pipeline("sentiment-analysis")
 
5
 
6
+ def predict_sentiment(text):
7
+ result = classifier(text)
8
+ return result[0]['label']
9
+
10
+ iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text", title = 'Sentiment Analysis')
11
+ iface.launch()