import gradio as gr from transformers import pipeline # Load sentiment analysis model classifier = pipeline("sentiment-analysis") # Prediction function def predict_sentiment(text): result = classifier(text)[0] label = result["label"] score = round(result["score"], 4) return f"Sentiment: {label} (Confidence: {score})" # Gradio UI app = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=3, placeholder="Enter your text here..."), outputs="text", title="BERT Sentiment Analysis", description="Enter text to classify sentiment as Positive or Negative" ) app.launch()