Spaces:
Runtime error
Runtime error
Changes
Browse files
app.py
CHANGED
|
@@ -75,11 +75,28 @@ def analyze_text(text: str):
|
|
| 75 |
🌐 URLs: {', '.join(urls) if urls else "None"}
|
| 76 |
"""
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
demo = gr.Interface(
|
| 80 |
-
fn=
|
| 81 |
inputs=gr.Textbox(lines=12, placeholder="Paste suspicious email or message here..."),
|
| 82 |
-
outputs="
|
| 83 |
title="PhishGuard 🛡️",
|
| 84 |
description="Detects phishing risks using regex cues + Hugging Face zero-shot classification."
|
| 85 |
)
|
|
|
|
| 75 |
🌐 URLs: {', '.join(urls) if urls else "None"}
|
| 76 |
"""
|
| 77 |
|
| 78 |
+
def predict_api(text: str):
|
| 79 |
+
regex_score, regex_findings = regex_analysis(text)
|
| 80 |
+
hf_score, hf_findings = hf_analysis(text)
|
| 81 |
+
|
| 82 |
+
score = min(100, regex_score + hf_score)
|
| 83 |
+
reasons = regex_findings + hf_findings
|
| 84 |
+
|
| 85 |
+
for phrase in SAFE_PHRASES:
|
| 86 |
+
if phrase in text.lower():
|
| 87 |
+
score = max(0, score - 15)
|
| 88 |
+
|
| 89 |
+
is_phishing = score >= 50
|
| 90 |
+
label = "phishing" if is_phishing else "safe"
|
| 91 |
+
confidence = score / 100.0
|
| 92 |
+
|
| 93 |
+
return [label, confidence]
|
| 94 |
+
|
| 95 |
+
# Gradio Interface with API enabled
|
| 96 |
demo = gr.Interface(
|
| 97 |
+
fn=predict_api,
|
| 98 |
inputs=gr.Textbox(lines=12, placeholder="Paste suspicious email or message here..."),
|
| 99 |
+
outputs="json",
|
| 100 |
title="PhishGuard 🛡️",
|
| 101 |
description="Detects phishing risks using regex cues + Hugging Face zero-shot classification."
|
| 102 |
)
|