import gradio as gr from transformers import pipeline # Load sentiment analysis model sentiment_model = pipeline("sentiment-analysis") def analyze_sentiment(text): result = sentiment_model(text)[0] return f"Label: {result['label']}, Score: {result['score']:.2f}" iface = gr.Interface( fn=analyze_sentiment, inputs=gr.Textbox(lines=2, placeholder="Type your text here..."), outputs="text", title="Sentiment Analysis", description="Enter a text to analyze its sentiment (Positive or Negative)." ) if __name__ == "__main__": iface.launch()