File size: 511 Bytes
f0967d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

classifier = pipeline('sentiment-analysis')

def sentiment_analysis(text):
    result = classifier(text)[0]
    return f"Label: {result['label']}, Score: {round(result['score'], 4)}"

iface = gr.Interface(
    fn=sentiment_analysis,
    inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
    outputs="text",
    title="Simple Sentiment Analysis",
    description="Enter a sentence and see if it's Positive or Negative!"
)

iface.launch()