import gradio as gr from transformers import pipeline # Load the pretrained sentiment pipeline sentiment_pipeline = pipeline("sentiment-analysis") def predict_sentiment(text): result = sentiment_pipeline(text)[0] label = result["label"] if label == "POSITIVE": return "✅ POSITIVE 😊" else: return "❌ NEGATIVE 😠" # Gradio Interface demo = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=3, placeholder="Type your sentence here..."), outputs="text", title="💬 LM Studios Sentiment Detector", description="Now powered by a Hugging Face transformer model for smarter predictions.", theme="default", flagging_mode="never" ) demo.launch()