SuryaR4421/Spam_Classification
0
1import streamlit as st
2import numpy as np
3import pickle
4from tensorflow.keras.models import load_model
5
6model = load_model("model.h5")
7with open("count_vec.pkl", "rb") as f:
8 vectorizer = pickle.load(f)
9
10def run():
11 st.title("Prediction - Spam Message Detection Model")
12 st.write("---")
13 st.image('ham_or_spam.jpg')
14
15 user_input = st.text_area("Enter the message to check for spam")
16
17 if st.button("Predict"):
18 if user_input:
19 user_input_vectorized = vectorizer.transform([user_input])
20
21 prediction = model.predict(user_input_vectorized)
22 prediction_class = np.argmax(prediction, axis=1)[0]
23
24 if prediction_class == 1:
25 st.error("This message is predicted to be SPAM!")
26 else:
27 st.success("This message is NOT spam.")
28 else:
29 st.warning("Please enter a message to classify.")
30
31if __name__ == '__main__':
32 run()
33 