File size: 670 Bytes
0c6b649
6615736
0c6b649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from transformers import pipeline
import gradio as gr

pipe = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")

def sentiment_analysis(inputText):
  result = pipe(inputText)
  return result[0]['label']

examples = [
    ["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."],
]

iface = gr.Interface(
    fn=sentiment_analysis,
    examples=examples,
    inputs=gr.Textbox(label='Enter a text to analyze'),
    outputs=gr.Textbox(label='Sentiment')
)

iface.launch()