Spaces:
Sleeping
Sleeping
File size: 1,050 Bytes
6f6aa2b | 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 29 30 31 32 33 34 35 | # app.py
import gradio as gr
from transformers import pipeline
# Load your model
print("β³ Loading model...")
classifier = pipeline("sentiment-analysis", model="jackenmail/sentiment-analysis")
print("β
Model ready!")
def get_sentiment(text):
if not text.strip():
return "β οΈ Please enter some text"
result = classifier(text)
label = result[0]["label"]
score = round(result[0]["score"] * 100, 2)
emoji = "π" if label == "POSITIVE" else "π"
return f"{emoji} {label} ({score}% confidence)"
# Gradio UI
demo = gr.Interface(
fn = get_sentiment,
inputs = gr.Textbox(placeholder="Enter text here...", label="Input Text"),
outputs = gr.Textbox(label="Sentiment Result"),
title = "π― Sentiment Analysis",
description = "Powered by jackenmail/sentiment-analysis",
examples = [
["I love this product!"],
["This is absolutely terrible."],
["Best purchase I ever made!"],
["I hate this, waste of money."]
]
)
demo.launch() |