File size: 684 Bytes
75db241
 
 
fc97056
75db241
 
 
 
fc97056
75db241
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

model_name = "ZombitX64/Thai-sentiment-e5"  # เปลี่ยนเป็นชื่อโมเดลของคุณ
nlp = pipeline("sentiment-analysis", model=model_name)

def analyze_text(text):
    result = nlp(text)[0]
    return f"ผลวิเคราะห์: {result['label']} (ความมั่นใจ {result['score']:.2f})"

demo = gr.Interface(
    fn=analyze_text,
    inputs=gr.Textbox(lines=3, placeholder="พิมพ์ข้อความที่นี่..."),
    outputs="text",
    title="แอปวิเคราะห์ข้อความภาษาไทย"
)

demo.launch()