Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a pre-trained text classification model
|
| 5 |
+
classifier = pipeline("text-classification", model="mohit-thakur/phishing-email-detection")
|
| 6 |
+
|
| 7 |
+
def detect_phishing(email_text):
|
| 8 |
+
result = classifier(email_text)[0]
|
| 9 |
+
label = result['label']
|
| 10 |
+
score = result['score']
|
| 11 |
+
return f"Prediction: {label} (Confidence: {score:.2f})"
|
| 12 |
+
|
| 13 |
+
# Gradio interface
|
| 14 |
+
interface = gr.Interface(
|
| 15 |
+
fn=detect_phishing,
|
| 16 |
+
inputs=gr.Textbox(lines=15, placeholder="Paste the email content here..."),
|
| 17 |
+
outputs="text",
|
| 18 |
+
title="Phishing Email Detector",
|
| 19 |
+
description="This app detects whether an email is a phishing attempt."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
interface.launch()
|