import gradio as gr from transformers import pipeline # Load the sentiment analysis model pipe = pipeline('sentiment-analysis') # Function to pass user input to the pipeline def analyze_sentiment(input_text): return pipe(input_text) # Create the Gradio interface demo = gr.Interface( fn=analyze_sentiment, inputs=gr.TextArea(label="Enter some text!"), outputs=gr.JSON(label="Sentiment Result") ) demo.launch()