File size: 827 Bytes
96da240
 
 
 
 
 
 
 
 
 
 
e4b6311
96da240
 
 
 
 
 
 
 
 
 
 
 
e47a513
96da240
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import pipeline
pipe_classification = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")     

# print(pipe_classification("i like this product")[0])
def classification_fun(sentence):
    result = pipe_classification(sentence)[0]
    return result["label"]

custom_css = """
body {
  background: #E3F2FD;
}
"""

ex = [
["I love this product! It's amazing!"],
["This was the worst experience I've ever had."],
["The movie was okay, not great but not bad either."],
["Absolutely fantastic! I would recommend it to everyone."]
]

intrface = gr.Interface(
    fn=classification_fun,
    inputs=gr.Textbox(label="Enter Your Sentence", lines=10),
    outputs=gr.Textbox(label="predicted sentiment"),
    examples=ex,
    css=custom_css
)

intrface.launch()