import gradio as gr from transformers import pipeline # Load pre-trained sentiment analysis model sentiment_model = pipeline("sentiment-analysis") # Define function to use the model def analyze_sentiment(text): result = sentiment_model(text)[0] return f"Label: {result['label']} | Confidence: {result['score']:.2f}" # Create Gradio interface demo = gr.Interface( fn=analyze_sentiment, inputs=gr.Textbox(lines=3, placeholder="Type a sentence here..."), outputs="text", title="Simple Sentiment Analyzer", description="Find out if your text is Positive or Negative using a BERT model." ) # Launch the app demo.launch()