SiemonCha commited on
Commit
e615bfe
·
verified ·
1 Parent(s): a8d8f9c

Upload app_spaces.py

Browse files
Files changed (1) hide show
  1. app_spaces.py +30 -0
app_spaces.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Simplified for Spaces
5
+ classifier = pipeline(
6
+ "text-classification",
7
+ model="SiemonCha/thai-sentiment-phayabert",
8
+ return_all_scores=True
9
+ )
10
+
11
+ LABELS = {"LABEL_0": "Positive 😊", "LABEL_1": "Neutral 😐", "LABEL_2": "Negative 😞"}
12
+
13
+ def predict(text):
14
+ results = classifier(text)[0]
15
+ return {LABELS[r['label']]: r['score'] for r in results}
16
+
17
+ demo = gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.Textbox(lines=3, placeholder="พิมพ์ข้อความภาษาไทย..."),
20
+ outputs=gr.Label(),
21
+ title="🇹🇭 Thai Sentiment Analysis",
22
+ description="Fine-tuned PhayaThaiBERT on 21k social media messages",
23
+ examples=[
24
+ ["อาหารอร่อยมาก บริการดีเยี่ยม"],
25
+ ["ราคาแพงไป คุณภาพไม่คุ้ม"],
26
+ ["ปกติครับ ไม่มีอะไรพิเศษ"],
27
+ ]
28
+ )
29
+
30
+ demo.launch()