Spaces:
Runtime error
Runtime error
Commit
·
f2bdb97
1
Parent(s):
517ee3a
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from keras import Sequential
|
| 4 |
-
from keras.layers import Dense,Embedding
|
| 5 |
from keras.utils import pad_sequences
|
| 6 |
from keras.preprocessing.text import Tokenizer
|
| 7 |
st.title("Spam-NonSpam Detector")
|
|
@@ -22,6 +22,7 @@ if st.button("Check"):
|
|
| 22 |
voc_size=len(tokenizer.word_index)
|
| 23 |
model = Sequential()
|
| 24 |
model.add(Embedding(voc_size+1,2,input_length=61))
|
|
|
|
| 25 |
model.add(Dense(5,activation="relu"))
|
| 26 |
model.add(Dense(5,activation="relu"))
|
| 27 |
model.add(Dense(1, activation='sigmoid'))
|
|
@@ -35,11 +36,11 @@ if st.button("Check"):
|
|
| 35 |
seq=tokenizer.texts_to_sequences(Input)
|
| 36 |
inp=pad_sequences(seq,padding='post',maxlen=61)
|
| 37 |
a=model.predict(inp)
|
| 38 |
-
value=a
|
| 39 |
st.text("Input:")
|
| 40 |
st.markdown(Input[0])
|
| 41 |
st.text("Output:")
|
| 42 |
-
if (value
|
| 43 |
st.text('Non-spam message')
|
| 44 |
else:
|
| 45 |
st.text('Spam message')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from keras import Sequential
|
| 4 |
+
from keras.layers import Dense,Embedding,Flatten
|
| 5 |
from keras.utils import pad_sequences
|
| 6 |
from keras.preprocessing.text import Tokenizer
|
| 7 |
st.title("Spam-NonSpam Detector")
|
|
|
|
| 22 |
voc_size=len(tokenizer.word_index)
|
| 23 |
model = Sequential()
|
| 24 |
model.add(Embedding(voc_size+1,2,input_length=61))
|
| 25 |
+
model.add(Flatten())
|
| 26 |
model.add(Dense(5,activation="relu"))
|
| 27 |
model.add(Dense(5,activation="relu"))
|
| 28 |
model.add(Dense(1, activation='sigmoid'))
|
|
|
|
| 36 |
seq=tokenizer.texts_to_sequences(Input)
|
| 37 |
inp=pad_sequences(seq,padding='post',maxlen=61)
|
| 38 |
a=model.predict(inp)
|
| 39 |
+
value=a[0][0]
|
| 40 |
st.text("Input:")
|
| 41 |
st.markdown(Input[0])
|
| 42 |
st.text("Output:")
|
| 43 |
+
if (value>0.5):
|
| 44 |
st.text('Non-spam message')
|
| 45 |
else:
|
| 46 |
st.text('Spam message')
|