Spaces:
Build error
Build error
Commit ·
474d7f1
1
Parent(s): 8698e03
Upload the application files
Browse files- app.py +21 -0
- localoutlierfactor.joblib +3 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Import dependencies
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import numpy as np
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
# Predict function
|
| 7 |
+
def predict(region1, region2, region3, region4, region5, region6):
|
| 8 |
+
model = joblib.load('./localoutlierfactor.joblib')
|
| 9 |
+
yhat = model.predict(np.array([[region1, region2, region3, region4, region5, region6]]))
|
| 10 |
+
return 'Weird Traffic' if yhat == -1 else 'Normal Traffic'
|
| 11 |
+
|
| 12 |
+
# Building the interface
|
| 13 |
+
app = gr.Interface(
|
| 14 |
+
title='Traffic Anomaly Detection 🚦',
|
| 15 |
+
fn=predict,
|
| 16 |
+
inputs=[gr.Slider(0,800),gr.Slider(0,800),gr.Slider(0,800),gr.Slider(0,800),gr.Slider(0,800),gr.Slider(0,800)],
|
| 17 |
+
outputs='text'
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Launch the app
|
| 21 |
+
app.launch()
|
localoutlierfactor.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:457527146fd9623882732251ab95714dfd1cc1ff12dd45e3b644588f8212f900
|
| 3 |
+
size 107489
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
scikit-learn==1.1.3
|