NimaKL commited on
Commit
22a0124
Β·
1 Parent(s): f199c54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -4,12 +4,14 @@ from textblob import TextBlob
4
  from transformers import BertForSequenceClassification, AdamW, BertConfig
5
  st.set_page_config(layout='wide', initial_sidebar_state='expanded')
6
  col1, col2= st.columns(2)
7
- flag = False
8
  with col1:
9
  st.title("Spamd: Turkish Spam Detector")
10
  st.markdown("Message spam detection tool for Turkish language. Due the small size of the dataset, I decided to go with transformers technology Google BERT. Using the Turkish pre-trained model BERTurk, I imporved the accuracy of the tool by 18 percent compared to the previous model which used fastText.")
11
-
12
- if st.button('Load Model', disabled=True):
 
 
13
  with st.spinner('Wait for it...'):
14
  import torch
15
  import numpy as np
@@ -55,10 +57,9 @@ if st.button('Load Model', disabled=True):
55
  prediction = 'Spam' if np.argmax(output.logits.cpu().numpy()).flatten().item() == 1 else 'Normal'
56
  pred = 'Predicted Class: '+ prediction
57
  return pred
58
- flag = True
59
- if flag:
60
  with col2:
61
- text = st.text_input("Enter the text you'd like to analyze for spam.")
62
  if text or st.button('Analyze'):
63
  st.header(predict(text))
64
 
 
4
  from transformers import BertForSequenceClassification, AdamW, BertConfig
5
  st.set_page_config(layout='wide', initial_sidebar_state='expanded')
6
  col1, col2= st.columns(2)
7
+ flag = True
8
  with col1:
9
  st.title("Spamd: Turkish Spam Detector")
10
  st.markdown("Message spam detection tool for Turkish language. Due the small size of the dataset, I decided to go with transformers technology Google BERT. Using the Turkish pre-trained model BERTurk, I imporved the accuracy of the tool by 18 percent compared to the previous model which used fastText.")
11
+ with col2:
12
+ text = st.text_input("Enter the text you'd like to analyze for spam.", disabled=flag)
13
+ st.button('Analyze')
14
+ if st.button('Load Model', disabled=False):
15
  with st.spinner('Wait for it...'):
16
  import torch
17
  import numpy as np
 
57
  prediction = 'Spam' if np.argmax(output.logits.cpu().numpy()).flatten().item() == 1 else 'Normal'
58
  pred = 'Predicted Class: '+ prediction
59
  return pred
60
+ flag = False
61
+ if not flag:
62
  with col2:
 
63
  if text or st.button('Analyze'):
64
  st.header(predict(text))
65