import gradio as gr from transformers import pipeline # Load the sentiment analysis model sentiment = pipeline("sentiment-analysis") def get_sentiment(input_text): result = sentiment(input_text) label = result[0]['label'] score = result[0]['score'] return f"Sentiment: {label}, Score: {score:.4f}" iface = gr.Interface( fn=get_sentiment, inputs="text", outputs="text", title="Sentiment Analysis with Transformers", description="Analyze sentiment (negative/positive) of input text." ) iface.launch(inline=False)