File size: 400 Bytes
7805bd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline

# Load the sentiment analysis model
classifier = pipeline('sentiment-analysis')

def sentiment_analysis(text):
    result = classifier(text)
    return result[0]['label'], result[0]['score']

# Create a Gradio interface
demo = gr.Interface(fn=sentiment_analysis, inputs="text", outputs=["text", "number"])

# Launch the Gradio app
demo.launch()