import gradio as gr from transformers import pipeline # Load the sentiment analysis model from Hugging Face sentiment_pipeline = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") # Define the prediction function def predict_sentiment(text): result = sentiment_pipeline(text)[0] return result['label'] # Create the Gradio interface iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text") # Launch the app iface.launch(server_name="0.0.0.0", server_port=7860)