Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load a
|
5 |
-
classifier = pipeline("text-classification", model="
|
6 |
|
|
|
7 |
def detect_phishing(email_text):
|
8 |
result = classifier(email_text)[0]
|
9 |
label = result['label']
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
# Gradio interface
|
14 |
interface = gr.Interface(
|
15 |
fn=detect_phishing,
|
16 |
-
inputs=gr.Textbox(lines=15, placeholder="Paste the email
|
17 |
outputs="text",
|
18 |
title="Phishing Email Detector",
|
19 |
-
description="This
|
20 |
)
|
21 |
|
|
|
22 |
if __name__ == "__main__":
|
23 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load a publicly available text classification model
|
5 |
+
classifier = pipeline("text-classification", model="BaptisteDoyen/fake-news-bert-base-uncased")
|
6 |
|
7 |
+
# Function to classify input text
|
8 |
def detect_phishing(email_text):
|
9 |
result = classifier(email_text)[0]
|
10 |
label = result['label']
|
11 |
+
confidence = result['score']
|
12 |
+
if label.lower() in ["fake", "FAKE"]:
|
13 |
+
verdict = "⚠️ This email looks suspicious or potentially phishing."
|
14 |
+
else:
|
15 |
+
verdict = "✅ This email looks legitimate."
|
16 |
+
return f"{verdict}\n\nPrediction: {label}\nConfidence: {confidence:.2f}"
|
17 |
|
18 |
+
# Build Gradio interface
|
19 |
interface = gr.Interface(
|
20 |
fn=detect_phishing,
|
21 |
+
inputs=gr.Textbox(lines=15, placeholder="Paste the email text here..."),
|
22 |
outputs="text",
|
23 |
title="Phishing Email Detector",
|
24 |
+
description="This tool uses a language model to help determine if an email is likely phishing or legitimate."
|
25 |
)
|
26 |
|
27 |
+
# Launch the app
|
28 |
if __name__ == "__main__":
|
29 |
interface.launch()
|