Download app.py from backzone1/Test: direct link, hf CLI and curl.
- Browser
- Download file 996 Bytes
-
https://huggingface.co/spaces/backzone1/Test/resolve/main/app.py
- Command line
-
hf download hf://spaces/backzone1/Test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/backzone1/Test/resolve/main/app.py
996 Bytes
| 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() | |