MoJaff commited on
Commit
0c6b649
·
verified ·
1 Parent(s): f9caaa5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ pipe = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
4
+
5
+ def sentiment_analysis(inputText):
6
+ result = pipe(inputText)
7
+ return result[0]['label']
8
+
9
+ examples = [
10
+ ["I love this product! It's amazing!"],
11
+ ["This was the worst experience I've ever had."],
12
+ ["The movie was okay, not great but not bad either."],
13
+ ["Absolutely fantastic! I would recommend it to everyone."],
14
+ ]
15
+
16
+ iface = gr.Interface(
17
+ fn=sentiment_analysis,
18
+ examples=examples,
19
+ inputs=gr.Textbox(label='Enter a text to analyze'),
20
+ outputs=gr.Textbox(label='Sentiment')
21
+ )
22
+
23
+ iface.launch()