dschandra commited on
Commit
3c6f21d
·
verified ·
1 Parent(s): 44fee5f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ from model.anomaly_detector import detect_anomaly
4
+
5
+ def process_input(json_input):
6
+ try:
7
+ input_data = json.loads(json_input)
8
+ result = detect_anomaly(input_data)
9
+ return json.dumps(result, indent=2)
10
+ except Exception as e:
11
+ return f"Error: {str(e)}"
12
+
13
+ iface = gr.Interface(
14
+ fn=process_input,
15
+ inputs=gr.Textbox(label="Input JSON", lines=10, placeholder='Paste agent data in JSON format'),
16
+ outputs="text",
17
+ title="Agent Behavior Anomaly Detector",
18
+ description="Detects abnormal agent behavior using Isolation Forest"
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ iface.launch()