vuminhtue commited on
Commit
459de8c
·
verified ·
1 Parent(s): eb61145

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from inference import SentimentClassifier
3
+
4
+ # Load classifier
5
+ classifier = SentimentClassifier(".")
6
+
7
+ def predict_sentiment(text):
8
+ """Predict sentiment and return results"""
9
+ result = classifier.predict(text)
10
+
11
+ return {
12
+ "Sentiment": result["sentiment"].upper(),
13
+ "Confidence": f"{result['confidence']:.2%}",
14
+ "Negative Probability": f"{result['probabilities']['negative']:.2%}",
15
+ "Positive Probability": f"{result['probabilities']['positive']:.2%}"
16
+ }
17
+
18
+ # Create interface
19
+ demo = gr.Interface(
20
+ fn=predict_sentiment,
21
+ inputs=gr.Textbox(
22
+ label="Enter text to analyze",
23
+ placeholder="Type your text here...",
24
+ lines=3
25
+ ),
26
+ outputs=gr.JSON(label="Prediction Results"),
27
+ title="🎭 Sentiment Analyzer",
28
+ description="Classify text as positive or negative using Qwen3 embeddings + Logistic Regression",
29
+ examples=[
30
+ ["This movie was absolutely wonderful!"],
31
+ ["Terrible experience, complete waste of time."],
32
+ ["It's okay, nothing special."]
33
+ ]
34
+ )
35
+
36
+ demo.launch()