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


sentiment = pipeline("sentiment-analysis")


def sentiment_analysis(text):
    
    results = sentiment(text)
    
    return results[0]["label"], round(results[0]["score"], 5)
    
demo = gr.Interface(
    fn = sentiment_analysis,
    inputs=gr.Textbox(lines=2, placeholder="Here...", label= 'Enter Text to Classify here'),
    outputs=[
        gr.Textbox(label = 'status'),
        gr.Textbox(label = 'score')
    ]
)
demo.launch()