SarahMarzouq commited on
Commit
96da240
·
verified ·
1 Parent(s): f2cc1ca

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ pipe_classification = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
4
+
5
+ # print(pipe_classification("i like this product")[0])
6
+ def classification_fun(sentence):
7
+ result = pipe_classification(sentence)[0]
8
+ return result["label"]
9
+
10
+ custom_css = """
11
+ body {
12
+ backgound-image: #E3F2FD;
13
+ background-size: cover;
14
+ background-repeat: no-repeat;
15
+ background-attachment: fixed;
16
+ }
17
+ """
18
+
19
+ ex = [
20
+ ["I love this product! It's amazing!"],
21
+ ["This was the worst experience I've ever had."],
22
+ ["The movie was okay, not great but not bad either."],
23
+ ["Absolutely fantastic! I would recommend it to everyone."]
24
+ ]
25
+
26
+ intrface = gr.Interface(
27
+ fn=classification_fun,
28
+ inputs=gr.Textbox(label="Enter Your Sentence"),
29
+ outputs=gr.Textbox(label="predicted sentiment"),
30
+ examples=ex,
31
+ css=custom_css
32
+ )
33
+
34
+ intrface.launch()