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