Spaces:
Sleeping
Sleeping
File size: 1,421 Bytes
d06d82c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
def build_ui(pipeline, target_encoder, predict_fn):
"""Build Gradio UI for intrusion detection."""
with gr.Blocks() as demo:
gr.Markdown("## 🔍 Network Threat Detection")
with gr.Row():
port = gr.Number(label="Port", value=80)
request_type = gr.Textbox(label="Request Type (e.g., GET, POST)")
protocol = gr.Textbox(label="Protocol (e.g., HTTP, HTTPS)")
payload_size = gr.Number(label="Payload Size", value=200)
user_agent = gr.Textbox(label="User Agent (e.g., Mozilla/5.0)")
status = gr.Textbox(label="Status (e.g., 200, 404)")
predict_btn = gr.Button("🚀 Predict Scan Type")
output = gr.Textbox(label="Prediction")
def on_predict(port, request_type, protocol, payload_size, user_agent, status):
features = {
"Port": port,
"Request_Type": request_type,
"Protocol": protocol,
"Payload_Size": payload_size,
"User_Agent": user_agent,
"Status": status,
}
return predict_fn(pipeline, target_encoder, features)
predict_btn.click(
on_predict,
inputs=[port, request_type, protocol, payload_size, user_agent, status],
outputs=[output],
)
return demo
|