sent2547 commited on
Commit
75db241
·
verified ·
1 Parent(s): d10ecf1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ model_name = "ZombitX64/Thai-sentiment-e5" # เปลี่ยนเป็นชื่อโมเดลของคุณ
5
+ nlp = pipeline("sentiment-analysis", model=model_name)
6
+
7
+ def analyze_text(text):
8
+ result = nlp(text)[0]
9
+ return f"ผลวิเคราะห์: {result['label']} (ความมั่นใจ {result['score']:.2f})"
10
+
11
+ demo = gr.Interface(
12
+ fn=analyze_text,
13
+ inputs=gr.Textbox(lines=3, placeholder="พิมพ์ข้อความที่นี่..."),
14
+ outputs="text",
15
+ title="แอปวิเคราะห์ข้อความภาษาไทย"
16
+ )
17
+
18
+ demo.launch()