Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
# Load the text classification model pipeline | |
classifier = pipeline("text-classification", model='kithangw/phishing_email_detection') | |
# Streamlit application title | |
st.title("Please enter a suspicious email") | |
# Text input for user to enter the email to classify | |
email = st.text_area("Enter the email to classify", "") | |
# Perform text classification when the user clicks the "Classify" button | |
if st.button("Classify"): | |
if email: # Check if email is not empty | |
# Perform text classification on the input email | |
results = classifier(email) | |
# The results variable contains a list with one item, which is a dictionary. | |
# The dictionary has 'label' and 'score' as keys. | |
result = results[0] | |
label = result['label'] | |
score = round(result['score'] * 100, 2) # Convert score to percentage | |
# Check the label and print out the corresponding message | |
if label == "LABEL_1": # Assuming LABEL_1 indicates phishing | |
st.write(f"The email you entered is {score}% likely to be a phishing email.") | |
else: # Assuming LABEL_0 indicates not phishing | |
st.write(f"The email you entered is {score}% likely to be not a phishing email.") | |
else: | |
st.error("Please enter an email to classify.") |