Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,23 +20,25 @@ def make(Flow_Bytes_per_s,Fwd_Packets_Length_Total,Init_Fwd_Win_Bytes,Packet_Len
|
|
20 |
10:"UDP",
|
21 |
11:"UDPLag",
|
22 |
12:"WebDDoS"}
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
40 |
headline ="""
|
41 |
Department of Information Technology \n
|
42 |
National Institute of Technology Karnataka \n
|
@@ -52,12 +54,6 @@ iface=gr.Interface(fn=make,
|
|
52 |
examples=[[9638.51,2088.0,-1,1130.1428,33.617596,0.0,0.0,0,-1,14,0.0,35.08846,0.0,96,0],
|
53 |
[21989.434,3552.0,257,442608.88,665.2886,1.0,1.0,0,386,20,6.0,877.0259,2.0,120,1],
|
54 |
[46730160.0,2944.0,-1,0.0,0.0,0.0,63.0,0,-1,-1062718972,0.0,0.0,63.0,-2125437944,0]
|
55 |
-
]
|
56 |
-
css="""
|
57 |
-
body{background-color: lightgreen}
|
58 |
-
.input_text input{
|
59 |
-
background-color: lightblue !important;
|
60 |
-
}
|
61 |
-
""")
|
62 |
# iface.launch(share=True)
|
63 |
iface.launch(share=True,debug=False,favicon_path="logo.png")
|
|
|
20 |
10:"UDP",
|
21 |
11:"UDPLag",
|
22 |
12:"WebDDoS"}
|
23 |
+
if l==[0]*15: return "Invalid Input"
|
24 |
+
else:
|
25 |
+
s=[]
|
26 |
+
s.append(l)
|
27 |
+
loaded_model = joblib.load('your_model.pkl')
|
28 |
+
predictions=loaded_model.predict(s)
|
29 |
+
# for i in range(len(predictions)):
|
30 |
+
# print("Prediction",i+1,':',reverse_encoding[predictions[i]])
|
31 |
+
import csv
|
32 |
+
input_file = "predictions.csv"
|
33 |
+
new_row = l
|
34 |
+
new_row.append(reverse_encoding[predictions[0]])
|
35 |
+
with open(input_file, 'r', newline='') as infile:
|
36 |
+
reader = csv.reader(infile)
|
37 |
+
data = list(reader)
|
38 |
+
with open(input_file, 'a', newline='') as outfile:
|
39 |
+
writer = csv.writer(outfile)
|
40 |
+
writer.writerow(new_row)
|
41 |
+
return reverse_encoding[predictions[0]]
|
42 |
headline ="""
|
43 |
Department of Information Technology \n
|
44 |
National Institute of Technology Karnataka \n
|
|
|
54 |
examples=[[9638.51,2088.0,-1,1130.1428,33.617596,0.0,0.0,0,-1,14,0.0,35.08846,0.0,96,0],
|
55 |
[21989.434,3552.0,257,442608.88,665.2886,1.0,1.0,0,386,20,6.0,877.0259,2.0,120,1],
|
56 |
[46730160.0,2944.0,-1,0.0,0.0,0.0,63.0,0,-1,-1062718972,0.0,0.0,63.0,-2125437944,0]
|
57 |
+
])
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
# iface.launch(share=True)
|
59 |
iface.launch(share=True,debug=False,favicon_path="logo.png")
|