File size: 996 Bytes
137d911
b669844
137d911
d4a2af3
b2b7084
6d59272
3ee3906
d4a2af3
137d911
6339358
b2b7084
 
 
 
b669844
5fcd732
6339358
 
 
 
b2b7084
5fcd732
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
from transformers import pipeline

pipe = pipeline(
    "text-classification",
    model="backzone1/autotrain-nelqy-yci82",  # โมเดลที่คุณเทรนเองและอัปโหลด
    tokenizer="backzone1/autotrain-nelqy-yci82"  # ให้ใช้ tokenizer จากโมเดลเดียวกัน
)

def classify_message(msg):
    result = pipe(msg)[0]
    label = result["label"]
    score = result["score"]
    return f"ผลลัพธ์: {label} (ความมั่นใจ {score:.2f})"

demo = gr.Interface(
    fn=classify_message,
    inputs=gr.Textbox(lines=5, label="พิมพ์ข้อความจาก LINE"),
    outputs=gr.Textbox(label="ผลลัพธ์"),
    title="จำแนกข้อความว่าเป็นงานหรือไม่",
    description="ใช้โมเดลที่ฝึกเองเพื่อจำแนกข้อความ"
)

demo.launch()