Update app.py
Browse files
app.py
CHANGED
|
@@ -9,13 +9,8 @@ from transformers import BertForSequenceClassification, AdamW, BertConfig
|
|
| 9 |
st.set_page_config(layout='wide', initial_sidebar_state='expanded')
|
| 10 |
st.title("Spamd: Turkish Spam Detector")
|
| 11 |
st.markdown("Enter the text you'd like to analyze for spam.")
|
| 12 |
-
text = st.text_input(
|
| 13 |
|
| 14 |
-
"""Spamd_SpamDetector_Turkish_BERT_22.09.2022.ipynb
|
| 15 |
-
|
| 16 |
-
Original file is located at
|
| 17 |
-
https://colab.research.google.com/drive/1QuorqAuLsmomesZHsaQHEZgzbPEM8YTH
|
| 18 |
-
"""
|
| 19 |
|
| 20 |
|
| 21 |
|
|
@@ -70,25 +65,9 @@ def predict(new_sentence):
|
|
| 70 |
output = model(test_ids.to(device), token_type_ids = None, attention_mask = test_attention_mask.to(device))
|
| 71 |
|
| 72 |
prediction = 'Spam' if np.argmax(output.logits.cpu().numpy()).flatten().item() == 1 else 'Normal'
|
| 73 |
-
st.
|
| 74 |
|
| 75 |
#st.write('Input', namestr(new_sentence, globals()),': \n', new_sentence)
|
| 76 |
# Remove the namestr(new_sentence, globals()) in case of an error
|
| 77 |
if st.button('Analyze'):
|
| 78 |
predict(text)
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
'''
|
| 84 |
-
@software{stefan_schweter_2020_3770924,
|
| 85 |
-
author = {Stefan Schweter},
|
| 86 |
-
title = {BERTurk - BERT models for Turkish},
|
| 87 |
-
month = apr,
|
| 88 |
-
year = 2020,
|
| 89 |
-
publisher = {Zenodo},
|
| 90 |
-
version = {1.0.0},
|
| 91 |
-
doi = {10.5281/zenodo.3770924},
|
| 92 |
-
url = {https://doi.org/10.5281/zenodo.3770924}
|
| 93 |
-
}
|
| 94 |
-
'''
|
|
|
|
| 9 |
st.set_page_config(layout='wide', initial_sidebar_state='expanded')
|
| 10 |
st.title("Spamd: Turkish Spam Detector")
|
| 11 |
st.markdown("Enter the text you'd like to analyze for spam.")
|
| 12 |
+
text = st.text_input()
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
|
|
|
|
| 65 |
output = model(test_ids.to(device), token_type_ids = None, attention_mask = test_attention_mask.to(device))
|
| 66 |
|
| 67 |
prediction = 'Spam' if np.argmax(output.logits.cpu().numpy()).flatten().item() == 1 else 'Normal'
|
| 68 |
+
st.header('Predicted Class: ', prediction)
|
| 69 |
|
| 70 |
#st.write('Input', namestr(new_sentence, globals()),': \n', new_sentence)
|
| 71 |
# Remove the namestr(new_sentence, globals()) in case of an error
|
| 72 |
if st.button('Analyze'):
|
| 73 |
predict(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|