Spaces:
Sleeping
Sleeping
| 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 | |