Spaces:
Sleeping
Sleeping
Download prediction.py from SuryaR4421/Spam_Classification: direct link, hf CLI and curl.
- Browser
- Download file 990 Bytes
-
https://huggingface.co/spaces/SuryaR4421/Spam_Classification/resolve/main/prediction.py
- Command line
-
hf download hf://spaces/SuryaR4421/Spam_Classification/prediction.py
-
curl -L -o prediction.py https://huggingface.co/spaces/SuryaR4421/Spam_Classification/resolve/main/prediction.py
990 Bytes
| import streamlit as st | |
| import numpy as np | |
| import pickle | |
| from tensorflow.keras.models import load_model | |
| model = load_model("model.h5") | |
| with open("count_vec.pkl", "rb") as f: | |
| vectorizer = pickle.load(f) | |
| def run(): | |
| st.title("Prediction - Spam Message Detection Model") | |
| st.write("---") | |
| st.image('ham_or_spam.jpg') | |
| user_input = st.text_area("Enter the message to check for spam") | |
| if st.button("Predict"): | |
| if user_input: | |
| user_input_vectorized = vectorizer.transform([user_input]) | |
| prediction = model.predict(user_input_vectorized) | |
| prediction_class = np.argmax(prediction, axis=1)[0] | |
| if prediction_class == 1: | |
| st.error("This message is predicted to be SPAM!") | |
| else: | |
| st.success("This message is NOT spam.") | |
| else: | |
| st.warning("Please enter a message to classify.") | |
| if __name__ == '__main__': | |
| run() | |