jackenmail commited on
Commit
6f6aa2b
·
verified ·
1 Parent(s): 65d5b11

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Load your model
6
+ print("⏳ Loading model...")
7
+ classifier = pipeline("sentiment-analysis", model="jackenmail/sentiment-analysis")
8
+ print("✅ Model ready!")
9
+
10
+ def get_sentiment(text):
11
+ if not text.strip():
12
+ return "⚠️ Please enter some text"
13
+
14
+ result = classifier(text)
15
+ label = result[0]["label"]
16
+ score = round(result[0]["score"] * 100, 2)
17
+ emoji = "😊" if label == "POSITIVE" else "😞"
18
+ return f"{emoji} {label} ({score}% confidence)"
19
+
20
+ # Gradio UI
21
+ demo = gr.Interface(
22
+ fn = get_sentiment,
23
+ inputs = gr.Textbox(placeholder="Enter text here...", label="Input Text"),
24
+ outputs = gr.Textbox(label="Sentiment Result"),
25
+ title = "🎯 Sentiment Analysis",
26
+ description = "Powered by jackenmail/sentiment-analysis",
27
+ examples = [
28
+ ["I love this product!"],
29
+ ["This is absolutely terrible."],
30
+ ["Best purchase I ever made!"],
31
+ ["I hate this, waste of money."]
32
+ ]
33
+ )
34
+
35
+ demo.launch()