File size: 1,204 Bytes
00d2792 | 1 2 3 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # streamlit_app.py
import streamlit as st
from models import load_model
from utils import mask_pii
st.set_page_config(page_title="π§ Email Classification System", page_icon="π§")
st.title("π§ Email Classification and PII Masking System")
# Load model
model = load_model("model/classifier.pkl")
# Prediction function
def classify_email_direct(email_body):
masked_text, entities = mask_pii(email_body)
category = model.predict([masked_text])[0]
return {
"input_email_body": email_body,
"list_of_masked_entities": entities,
"masked_email": masked_text,
"category_of_the_email": category
}
# Streamlit UI
email_input = st.text_area("βοΈ Enter your email text:")
if st.button("π Classify Email"):
if email_input.strip() != "":
result = classify_email_direct(email_input)
st.subheader("π Masked Email")
st.write(result['masked_email'])
st.subheader("π List of Masked Entities")
st.json(result['list_of_masked_entities'])
st.subheader("π Predicted Category")
st.success(result['category_of_the_email'])
else:
st.warning("β οΈ Please enter some text first.")
|