Update streamlit_app.py
Browse files- streamlit_app.py +41 -28
streamlit_app.py
CHANGED
|
@@ -1,28 +1,41 @@
|
|
| 1 |
-
# streamlit_app.py
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# streamlit_app.py
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from models import load_model
|
| 4 |
+
from utils import mask_pii
|
| 5 |
+
|
| 6 |
+
st.set_page_config(page_title="π§ Email Classification System", page_icon="π§")
|
| 7 |
+
|
| 8 |
+
st.title("π§ Email Classification and PII Masking System")
|
| 9 |
+
|
| 10 |
+
# Load model
|
| 11 |
+
model = load_model("model/classifier.pkl")
|
| 12 |
+
|
| 13 |
+
# Prediction function
|
| 14 |
+
def classify_email_direct(email_body):
|
| 15 |
+
masked_text, entities = mask_pii(email_body)
|
| 16 |
+
category = model.predict([masked_text])[0]
|
| 17 |
+
return {
|
| 18 |
+
"input_email_body": email_body,
|
| 19 |
+
"list_of_masked_entities": entities,
|
| 20 |
+
"masked_email": masked_text,
|
| 21 |
+
"category_of_the_email": category
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
# Streamlit UI
|
| 25 |
+
email_input = st.text_area("βοΈ Enter your email text:")
|
| 26 |
+
|
| 27 |
+
if st.button("π Classify Email"):
|
| 28 |
+
if email_input.strip() != "":
|
| 29 |
+
result = classify_email_direct(email_input)
|
| 30 |
+
|
| 31 |
+
st.subheader("π Masked Email")
|
| 32 |
+
st.write(result['masked_email'])
|
| 33 |
+
|
| 34 |
+
st.subheader("π List of Masked Entities")
|
| 35 |
+
st.json(result['list_of_masked_entities'])
|
| 36 |
+
|
| 37 |
+
st.subheader("π Predicted Category")
|
| 38 |
+
st.success(result['category_of_the_email'])
|
| 39 |
+
else:
|
| 40 |
+
st.warning("β οΈ Please enter some text first.")
|
| 41 |
+
|