vk commited on
Commit
81dce6e
·
1 Parent(s): 25038c9
Files changed (2) hide show
  1. app.py +6 -3
  2. yolox_onnx.py +0 -1
app.py CHANGED
@@ -2,6 +2,7 @@ from yolox_onnx import YOLOX_ONNX
2
  import albumentations as A
3
  import gradio as gr
4
  import cv2
 
5
 
6
  def show_example(path):
7
  return cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
@@ -27,8 +28,10 @@ def get_response(input_img,add_snow,add_rain,add_fog,confidence_threshold,iou_th
27
  if not hasattr(input_img,'shape'):
28
  return "invalid input",input_img
29
 
 
 
30
  pedestrian_detector.predict(input_img,confidence_threshold,iou_threshold)
31
- out_img=pedestrian_detector.output_img
32
 
33
  if add_snow:
34
  out_img = weather_transform["add_snow"] (image=out_img)['image']
@@ -40,7 +43,7 @@ def get_response(input_img,add_snow,add_rain,add_fog,confidence_threshold,iou_th
40
  pass
41
 
42
 
43
- return out_img
44
 
45
 
46
  if __name__ == "__main__":
@@ -59,7 +62,7 @@ if __name__ == "__main__":
59
  gr.Checkbox(label="add_rain"),
60
  gr.Checkbox(label="add_fog"),
61
  gr.Slider(0, 1,value=0.5, step=0.01, label="confidence_threshold"),
62
- gr.Slider(0, 1,value=0.45, step=0.01, label="iou_threshold")],
63
  examples=[[show_example('test-images/test1.jpg')],[show_example('test-images/test2.jpg')],[show_example('test-images/test3.jpg')]],
64
  outputs=[gr.Image(type="numpy")],
65
  title="Pedestrian Detection with All weather augmentation",
 
2
  import albumentations as A
3
  import gradio as gr
4
  import cv2
5
+ import numpy as np
6
 
7
  def show_example(path):
8
  return cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
 
28
  if not hasattr(input_img,'shape'):
29
  return "invalid input",input_img
30
 
31
+ input_img=cv2.cvtColor(input_img,cv2.COLOR_RGB2BGR).astype(np.float32)
32
+
33
  pedestrian_detector.predict(input_img,confidence_threshold,iou_threshold)
34
+ out_img=pedestrian_detector.output_img.astype(np.uint8)
35
 
36
  if add_snow:
37
  out_img = weather_transform["add_snow"] (image=out_img)['image']
 
43
  pass
44
 
45
 
46
+ return cv2.cvtColor(out_img,cv2.COLOR_BGR2RGB)
47
 
48
 
49
  if __name__ == "__main__":
 
62
  gr.Checkbox(label="add_rain"),
63
  gr.Checkbox(label="add_fog"),
64
  gr.Slider(0, 1,value=0.5, step=0.01, label="confidence_threshold"),
65
+ gr.Slider(0, 1,value=0.4, step=0.01, label="iou_threshold")],
66
  examples=[[show_example('test-images/test1.jpg')],[show_example('test-images/test2.jpg')],[show_example('test-images/test3.jpg')]],
67
  outputs=[gr.Image(type="numpy")],
68
  title="Pedestrian Detection with All weather augmentation",
yolox_onnx.py CHANGED
@@ -2,7 +2,6 @@ import cv2
2
  from time import time
3
  import numpy as np
4
  import onnxruntime
5
- from collections import defaultdict
6
 
7
 
8
  class YOLOX_ONNX:
 
2
  from time import time
3
  import numpy as np
4
  import onnxruntime
 
5
 
6
 
7
  class YOLOX_ONNX: