walkermanj's picture
Update app.py
0f442d1 verified
raw
history blame
725 Bytes
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()