import gradio as gr from transformers import pipeline # Load Sentiment Analysis Model sentiment_pipeline = pipeline("sentiment-analysis") # Define Function for Prediction def analyze_sentiment(text): result = sentiment_pipeline(text) return result[0]["label"], result[0]["score"] # Create Gradio Interface iface = gr.Interface( fn=analyze_sentiment, inputs=gr.Textbox(label="Enter Text"), outputs=[gr.Textbox(label="Sentiment"), gr.Textbox(label="Confidence Score")], title="Sentiment Analysis App", description="Enter a sentence and get its sentiment (Positive/Negative).", ) iface.launch()