jackenmail's picture
Create app.py
6f6aa2b verified
# 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()