File size: 593 Bytes
93857ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr

from transformers import pipeline

sentiment = pipeline("sentiment-analysis")

def get_sentiment(input_text):
    return f"The sentiment was {sentiment(input_text)[0]['label']} and the probabilty is {round(sentiment(input_text)[0]['score'] * 100, 2)} %"
    
iface = gr.Interface(fn=get_sentiment, 
                     inputs='text',
                     outputs=['text'],
                     title="Sentiment Analysis",
                     description="Get sentiment Negative/Positive for the given input",
                     live=True)

iface.launch(inline = False)