Mahit commited on
Commit
aa24e6b
1 Parent(s): c01ea71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -24
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
- s=[]
24
- s.append(l)
25
- loaded_model = joblib.load('your_model.pkl')
26
- predictions=loaded_model.predict(s)
27
- # for i in range(len(predictions)):
28
- # print("Prediction",i+1,':',reverse_encoding[predictions[i]])
29
- import csv
30
- input_file = "predictions.csv"
31
- new_row = l
32
- new_row.append(reverse_encoding[predictions[0]])
33
- with open(input_file, 'r', newline='') as infile:
34
- reader = csv.reader(infile)
35
- data = list(reader)
36
- with open(input_file, 'a', newline='') as outfile:
37
- writer = csv.writer(outfile)
38
- writer.writerow(new_row)
39
- return reverse_encoding[predictions[0]]
 
 
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")