kithangw commited on
Commit
b11db75
·
verified ·
1 Parent(s): 8e65051

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the text classification model pipeline
5
+ classifier = pipeline("text-classification", model='kithangw/phishing_email_detection')
6
+
7
+ # Streamlit application title
8
+ st.title("Please enter a suspicious email")
9
+
10
+ # Text input for user to enter the email to classify
11
+ email = st.text_area("Enter the email to classify", "")
12
+
13
+ # Perform text classification when the user clicks the "Classify" button
14
+ if st.button("Classify"):
15
+ if email: # Check if email is not empty
16
+ # Perform text classification on the input email
17
+ results = classifier(email)
18
+
19
+ # The results variable contains a list with one item, which is a dictionary.
20
+ # The dictionary has 'label' and 'score' as keys.
21
+ result = results[0]
22
+ label = result['label']
23
+ score = round(result['score'] * 100, 2) # Convert score to percentage
24
+
25
+ # Check the label and print out the corresponding message
26
+ if label == "LABEL_1": # Assuming LABEL_1 indicates phishing
27
+ st.write(f"The email you entered is {score}% likely to be a phishing email.")
28
+ else: # Assuming LABEL_0 indicates not phishing
29
+ st.write(f"The email you entered is {score}% likely to be not a phishing email.")
30
+ else:
31
+ st.error("Please enter an email to classify.")
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ spaces
2
+ transformers
3
+ torch
4
+ evaluate
5
+ transformers[torch]