Spaces:
Sleeping
Sleeping
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() | |