Spaces:
Running
Running
File size: 725 Bytes
8e2c54a 0f442d1 8e2c54a 0f442d1 8e2c54a 0f442d1 8e2c54a 0f442d1 8e2c54a 0f442d1 8e2c54a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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()
|