|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
|
|
|
pipe = pipeline( |
|
|
"text-classification", |
|
|
model="backzone1/autotrain-nelqy-yci82", |
|
|
tokenizer="backzone1/autotrain-nelqy-yci82" |
|
|
) |
|
|
|
|
|
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() |
|
|
|