Tlezz324 commited on
Commit
5c403f1
·
verified ·
1 Parent(s): bdd46c5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
+ import torch
3
+ import gradio as gr
4
+
5
+ model_name = "Tlezz324/thai-scam-detector-v1.69"
6
+
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
9
+
10
+ def predict(text):
11
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
12
+ with torch.no_grad():
13
+ logits = model(**inputs).logits
14
+ pred = torch.argmax(logits, dim=1).item()
15
+ return "Scam" if pred == 1 else "Not Scam"
16
+
17
+ iface = gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.Textbox(lines=4, placeholder="พิมพ์ข้อความที่ต้องการตรวจสอบ..."),
20
+ outputs="text",
21
+ title="Thai Scam Detector Demo",
22
+ description="โมเดลตรวจจับข้อความหลอกลวงภาษาไทย"
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ iface.launch()