File size: 1,348 Bytes
b11db75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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.")