sbicy commited on
Commit
f0967d5
·
verified ·
1 Parent(s): b32d9f5

Create app.py

Browse files

a very vanilla model for demonstrating sentiment analysis

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
+ classifier = pipeline('sentiment-analysis')
5
+
6
+ def sentiment_analysis(text):
7
+ result = classifier(text)[0]
8
+ return f"Label: {result['label']}, Score: {round(result['score'], 4)}"
9
+
10
+ iface = gr.Interface(
11
+ fn=sentiment_analysis,
12
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
13
+ outputs="text",
14
+ title="Simple Sentiment Analysis",
15
+ description="Enter a sentence and see if it's Positive or Negative!"
16
+ )
17
+
18
+ iface.launch()