dungeon29 commited on
Commit
44089aa
·
verified ·
1 Parent(s): 83fcd8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -54
app.py CHANGED
@@ -326,73 +326,80 @@ def predict_fn(text: str):
326
  return prediction_result, detailed_analysis
327
 
328
  # --------- Gradio UI ----------
329
- deberta_interface = gr.Interface(
330
- fn=predict_fn,
331
- inputs=gr.Textbox(label="URL or text", placeholder="Example: http://suspicious-site.example or paste any text"),
332
- outputs=[
333
- gr.Label(label="Prediction result"),
334
- gr.Markdown(label="Detailed token analysis")
335
- ],
336
- title="Phishing Detector (DeBERTa + LSTM)",
337
- description="""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- examples=[
354
- ["http://rendmoiunserviceeee.com"],
355
- ["https://www.google.com"],
356
- ["Dear customer, your account has been suspended. Click here to verify your identity immediately."],
357
- ["https://mail-secure-login-verify.example/path?token=suspicious"],
358
- ["http://paypaI-security-update.net/login"],
359
- ["Your package has been delivered successfully. Thank you for using our service."],
360
- ["https://github.com/user/repo"]
361
- ],
362
- css="""
363
- .gradio-container {
364
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
365
- background-color: #1e1e1e !important;
366
- color: #ffffff !important;
367
- }
368
- .dark .gradio-container {
369
- background-color: #1e1e1e !important;
370
- }
371
- /* Dark theme for all components */
372
- .block {
373
- background-color: #2d2d2d !important;
374
- border: 1px solid #444 !important;
375
- }
376
- .gradio-textbox {
377
- background-color: #3d3d3d !important;
378
- color: #ffffff !important;
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
- demo = gr.TabbedInterface(
393
- [deberta_interface],
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()