Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,28 +5,24 @@ tokenizer = AutoTokenizer.from_pretrained("nlptown/bert-base-multilingual-uncase
|
|
5 |
model = AutoModelForSequenceClassification.from_pretrained("nlptown/bert-base-multilingual-uncased-sentiment")
|
6 |
|
7 |
# Create a sentiment analysis pipeline with the explicit tokenizer
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
|
|
|
|
15 |
if user_input:
|
16 |
-
#
|
17 |
-
result =
|
18 |
-
label = result[0]['label']
|
19 |
-
score = result[0]['score']
|
20 |
|
21 |
# แสดงผลลัพธ์
|
22 |
-
st.write(
|
23 |
-
st.write(f"
|
24 |
-
|
25 |
-
|
26 |
-
if label == "spam":
|
27 |
-
st.warning("ข้อความนี้ถูกตรวจสแปม")
|
28 |
-
else:
|
29 |
-
st.success("ข้อความนี้ไม่ใช่สแปม")
|
30 |
else:
|
31 |
-
st.warning("
|
32 |
-
|
|
|
5 |
model = AutoModelForSequenceClassification.from_pretrained("nlptown/bert-base-multilingual-uncased-sentiment")
|
6 |
|
7 |
# Create a sentiment analysis pipeline with the explicit tokenizer
|
8 |
+
classifier = pipeline("text-classification", model=model)
|
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 |
+
st.write(f"สปัม: {result[0]['label']}")
|
26 |
+
st.write(f"ความมั่นใจ: {result[0]['score']}")
|
|
|
|
|
|
|
|
|
27 |
else:
|
28 |
+
st.warning("โปรดป้อนข้อความก่อนตรวจสอบ")
|
|