Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -326,73 +326,80 @@ def predict_fn(text: str):
|
|
| 326 |
return prediction_result, detailed_analysis
|
| 327 |
|
| 328 |
# --------- Gradio UI ----------
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
Enter a URL or text for analysis.
|
| 339 |
**Features:**
|
| 340 |
- **URL Analysis**: For URLs, the system will fetch HTML content and combine both URL and content analysis
|
| 341 |
-
- **Combined Prediction**: Uses weighted combination of URL structure and webpage content analysis
|
| 342 |
- **Visual Analysis**: Predict phishing/benign probability with visual charts
|
| 343 |
- **Token Importance**: Display the most important tokens in classification
|
| 344 |
- **Detailed Insights**: Comprehensive analysis of the impact of each token
|
| 345 |
-
- **Dark Theme**: Beautiful interface with colorful charts optimized for dark themes
|
| 346 |
|
| 347 |
**How it works for URLs:**
|
| 348 |
1. Analyze the URL structure itself
|
| 349 |
2. Fetch the webpage HTML content
|
| 350 |
3. Analyze the webpage content
|
| 351 |
4. Combine both results for final prediction (30% URL + 70% content)
|
| 352 |
-
"""
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
border: 1px solid #666 !important;
|
| 380 |
-
}
|
| 381 |
-
.gradio-button {
|
| 382 |
-
background-color: #4a4a4a !important;
|
| 383 |
-
color: #ffffff !important;
|
| 384 |
-
border: 1px solid #666 !important;
|
| 385 |
-
}
|
| 386 |
-
.gradio-button:hover {
|
| 387 |
-
background-color: #5a5a5a !important;
|
| 388 |
-
}
|
| 389 |
-
"""
|
| 390 |
-
)
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
["DeBERTa + LSTM"]
|
| 395 |
-
)
|
| 396 |
|
| 397 |
if __name__ == "__main__":
|
| 398 |
demo.launch()
|
|
|
|
| 326 |
return prediction_result, detailed_analysis
|
| 327 |
|
| 328 |
# --------- Gradio UI ----------
|
| 329 |
+
css_style="""
|
| 330 |
+
.gradio-container {
|
| 331 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 332 |
+
background-color: #1e1e1e !important;
|
| 333 |
+
color: #ffffff !important;
|
| 334 |
+
}
|
| 335 |
+
.dark .gradio-container {
|
| 336 |
+
background-color: #1e1e1e !important;
|
| 337 |
+
}
|
| 338 |
+
/* Dark theme for all components */
|
| 339 |
+
.block {
|
| 340 |
+
background-color: #2d2d2d !important;
|
| 341 |
+
border: 1px solid #444 !important;
|
| 342 |
+
}
|
| 343 |
+
.gradio-textbox {
|
| 344 |
+
background-color: #3d3d3d !important;
|
| 345 |
+
color: #ffffff !important;
|
| 346 |
+
border: 1px solid #666 !important;
|
| 347 |
+
}
|
| 348 |
+
.gradio-button {
|
| 349 |
+
background-color: #4a4a4a !important;
|
| 350 |
+
color: #ffffff !important;
|
| 351 |
+
border: 1px solid #666 !important;
|
| 352 |
+
}
|
| 353 |
+
.gradio-button:hover {
|
| 354 |
+
background-color: #5a5a5a !important;
|
| 355 |
+
}
|
| 356 |
+
"""
|
| 357 |
+
with gr.Blocks(css=css_style) as demo:
|
| 358 |
+
gr.Markdown("# 🛡️ Phishing Detector (DeBERTa + LSTM)")
|
| 359 |
+
gr.Markdown("""
|
| 360 |
Enter a URL or text for analysis.
|
| 361 |
**Features:**
|
| 362 |
- **URL Analysis**: For URLs, the system will fetch HTML content and combine both URL and content analysis
|
| 363 |
+
- **Combined Prediction**: Uses weighted combination of URL structure and webpage content analysis
|
| 364 |
- **Visual Analysis**: Predict phishing/benign probability with visual charts
|
| 365 |
- **Token Importance**: Display the most important tokens in classification
|
| 366 |
- **Detailed Insights**: Comprehensive analysis of the impact of each token
|
|
|
|
| 367 |
|
| 368 |
**How it works for URLs:**
|
| 369 |
1. Analyze the URL structure itself
|
| 370 |
2. Fetch the webpage HTML content
|
| 371 |
3. Analyze the webpage content
|
| 372 |
4. Combine both results for final prediction (30% URL + 70% content)
|
| 373 |
+
""")
|
| 374 |
+
|
| 375 |
+
with gr.Row():
|
| 376 |
+
with gr.Column(scale=2):
|
| 377 |
+
input_box = gr.Textbox(
|
| 378 |
+
label="URL or text",
|
| 379 |
+
placeholder="Example: http://suspicious-site.example or paste any text",
|
| 380 |
+
lines=3
|
| 381 |
+
)
|
| 382 |
+
btn_submit = gr.Button("🔍 Analyze", variant="primary")
|
| 383 |
+
|
| 384 |
+
gr.Examples(
|
| 385 |
+
examples=[
|
| 386 |
+
["http://rendmoiunserviceeee.com"],
|
| 387 |
+
["https://www.google.com"],
|
| 388 |
+
["Dear customer, your account has been suspended. Click here to verify your identity immediately."],
|
| 389 |
+
["https://mail-secure-login-verify.example/path?token=suspicious"],
|
| 390 |
+
["http://paypaI-security-update.net/login"],
|
| 391 |
+
["Your package has been delivered successfully. Thank you for using our service."],
|
| 392 |
+
["https://github.com/user/repo"]
|
| 393 |
+
],
|
| 394 |
+
inputs=input_box
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
with gr.Column(scale=3):
|
| 398 |
+
# Output là HTML để hiển thị báo cáo đẹp mắt
|
| 399 |
+
output_html = gr.HTML(label="Analysis Result")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
|
| 401 |
+
# Kết nối nút bấm với hàm xử lý
|
| 402 |
+
btn_submit.click(fn=predict_fn, inputs=input_box, outputs=output_html)
|
|
|
|
|
|
|
| 403 |
|
| 404 |
if __name__ == "__main__":
|
| 405 |
demo.launch()
|