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


sentiment = pipeline('sentiment-analysis',)

def get_sentiment(input_text):
    result = sentiment(input_text)
    return f"result: {result[0]['label']}", f"score: {result[0]['score']}"

interface = gr.Interface(
    fn=get_sentiment,
    inputs='text',
    outputs=['text', 'text'],
    title='Sentiment Analysis',
    description='Get the positive/negative sentiment for the given input.'
)


interface.launch(inline = False)