Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 3 |
-
|
| 4 |
-
tokenizer = AutoTokenizer.from_pretrained("Nma/RuleClassify-Textclassify")
|
| 5 |
-
model = AutoModelForSequenceClassification.from_pretrained("Nma/RuleClassify-Textclassify")
|
| 6 |
-
|
| 7 |
-
# Create a sentiment analysis pipeline with the explicit tokenizer
|
| 8 |
-
classifier = pipeline("text-classification", model=model,tokenizer=tokenizer)
|
| 9 |
-
|
| 10 |
-
# สร้างหน้าเว็บ Streamlit
|
| 11 |
-
st.title("Spam Detection App")
|
| 12 |
-
|
| 13 |
-
# สร้างกล่องข้อความให้ผู้ใช้ป้อนข้อความ
|
| 14 |
-
user_input = st.text_input("ใส่ข้อความที่ต้องการตรวจสอบ:")
|
| 15 |
-
|
| 16 |
-
# ตรวจสอบข้อความเมื่อผู้ใช้กดปุ่ม "ตรวจสอบ"
|
| 17 |
-
if st.button("ตรวจสอบ"):
|
| 18 |
-
if user_input:
|
| 19 |
-
# ใช้โมเดลตรวจสอบข้อความ
|
| 20 |
-
result = classifier(user_input)
|
| 21 |
-
|
| 22 |
-
# แสดงผลลัพธ์
|
| 23 |
-
st.write("ผลลัพธ์:")
|
| 24 |
-
st.write(f"ข้อความ: {user_input}")
|
| 25 |
-
|
| 26 |
-
# แสดงค่าความมั่นใจ
|
| 27 |
-
confidence = result[0]['score'] * 100 # แปลงค่าความมั่นใจเป็นเปอร์เซ็นต์
|
| 28 |
-
label = result[0]['label']
|
| 29 |
-
|
| 30 |
-
if label == "LABEL_FOR_SPAM": # แทน LABEL_FOR_SPAM ด้วยป้ายกำกับสแปมของโมเดลของคุณ
|
| 31 |
-
st.write(f"สแปม: {label} ({confidence:.2f}% ความมั่นใจ)")
|
| 32 |
-
if confidence >= 80:
|
| 33 |
-
st.warning("โมเดลมั่นใจว่าข้อความนี้ไม่เป็นสแปม")
|
| 34 |
-
else:
|
| 35 |
-
st.success("โมเดลมั่นใจว่าข้อความนี้เป็นสแปม")
|
| 36 |
-
else:
|
| 37 |
-
st.write(f"ไม่เป็นสแปม: {label} ({confidence:.2f}% ความมั่นใจ)")
|
| 38 |
-
st.success("โมเดลมั่นใจว่าข้อความนี้ไม่เป็นสแปม")
|
| 39 |
-
else:
|
| 40 |
-
st.warning("โปรดป้อนข้อความก่อนตรวจสอบ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|