import gradio as gr from transformers import pipeline classifier=pipeline("sentiment-analysis") # Load sentiment analysis pipeline sentiment_pipeline = pipeline("sentiment-analysis") text = "I absolutely love this app! It's amazing." # Define function to use in Gradio def analyze_sentiment(text): result = sentiment_pipeline(text)[0] label = result['label'] score = result['score'] return f"Sentiment: {label} (confidence: {score})" return result # Create Gradio interface demo = gr.Interface(fn=analyze_sentiment, inputs=gr.Textbox(lines=4, placeholder="Enter text here..."), outputs="text", title="Sentiment Analysis App", description="Enter text and get the sentiment prediction using a Hugging Face transformer model.") # Launch app if __name__ == "__main__": demo.launch()