Download src/streamlit_app.py from remiXr/test1: direct link, hf CLI and curl.
- Browser
- Download file 684 Bytes
-
https://huggingface.co/spaces/remiXr/test1/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/remiXr/test1/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/remiXr/test1/resolve/main/src/streamlit_app.py
684 Bytes
| import joblib | |
| import os | |
| import streamlit as st | |
| st.set_page_config(page_title="Simple Model Demo", page_icon="🧠") | |
| st.title("🧠 Simple ML Model (Spam Classifier)") | |
| def load_model(): | |
| model_path = os.path.join(os.path.dirname(__file__), "model", "train.joblib") | |
| return joblib.load(model_path) | |
| model = load_model() | |
| text = st.text_area("Enter a message", "Win a free iPhone now!") | |
| if st.button("Predict"): | |
| pred = model.predict([text])[0] | |
| proba = model.predict_proba([text])[0][1] # probability of spam (class 1) | |
| label = "SPAM 🚨" if pred == 1 else "NOT SPAM ✅" | |
| st.subheader(label) | |
| st.write(f"Spam probability: **{proba:.2f}**") | |