@@ -22,9 +22,6 @@ class YOLO:
2222
2323    @classmethod  
2424    def  add_plugin (cls , network ):
25-         """ 
26-         Adapted from https://github.com/jkjung-avt/tensorrt_demos 
27-         """ 
2825        def  get_plugin_creator (plugin_name ):
2926            plugin_creators  =  trt .get_plugin_registry ().plugin_creator_list 
3027            for  plugin_creator  in  plugin_creators :
@@ -107,6 +104,114 @@ class YOLOv4(YOLO):
107104    INPUT_SHAPE  =  (3 , 512 , 512 )
108105    LAYER_FACTORS  =  [8 , 16 , 32 ]
109106    SCALES  =  [1.2 , 1.1 , 1.05 ]
110-     ANCHORS  =  [[11 , 22 , 24 , 60 , 37 , 116 ],
111-                [54 , 186 , 69 , 268 , 89 , 369 ],
112-                [126 , 491 , 194 , 314 , 278 , 520 ]]
107+     ANCHORS  =  [[11 ,22 , 24 ,60 , 37 ,116 ],
108+                [54 ,186 , 69 ,268 , 89 ,369 ],
109+                [126 ,491 , 194 ,314 , 278 ,520 ]]
110+ 
111+ 
112+ """ 
113+ The following models are supported but not provided. 
114+ Modify paths, # classes, input shape, and anchors according to your Darknet cfg for custom model. 
115+ """ 
116+ 
117+ class  YOLOv4CSP (YOLO ):
118+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov4-csp.trt' 
119+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov4-csp.onnx' 
120+     NUM_CLASSES  =  1 
121+     LETTERBOX  =  True 
122+     NEW_COORDS  =  True 
123+     INPUT_SHAPE  =  (3 , 512 , 512 )
124+     LAYER_FACTORS  =  [8 , 16 , 32 ]
125+     SCALES  =  [2.0 , 2.0 , 2.0 ]
126+     ANCHORS  =  [[12 ,16 , 19 ,36 , 40 ,28 ],
127+                [36 ,75 , 76 ,55 , 72 ,146 ],
128+                [142 ,110 , 192 ,243 , 459 ,401 ]]
129+ 
130+ 
131+ class  YOLOv4xMish (YOLO ):
132+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov4x-mish.trt' 
133+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov4x-mish.onnx' 
134+     NUM_CLASSES  =  1 
135+     LETTERBOX  =  True 
136+     NEW_COORDS  =  True 
137+     INPUT_SHAPE  =  (3 , 640 , 640 )
138+     LAYER_FACTORS  =  [8 , 16 , 32 ]
139+     SCALES  =  [2.0 , 2.0 , 2.0 ]
140+     ANCHORS  =  [[12 ,16 , 19 ,36 , 40 ,28 ],
141+                [36 ,75 , 76 ,55 , 72 ,146 ],
142+                [142 ,110 , 192 ,243 , 459 ,401 ]]
143+ 
144+ 
145+ class  YOLOv4P5 (YOLO ):
146+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov4-p5.trt' 
147+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov4-p5.onnx' 
148+     NUM_CLASSES  =  1 
149+     LETTERBOX  =  True 
150+     NEW_COORDS  =  True 
151+     INPUT_SHAPE  =  (3 , 896 , 896 )
152+     LAYER_FACTORS  =  [8 , 16 , 32 ]
153+     SCALES  =  [2.0 , 2.0 , 2.0 ]
154+     ANCHORS  =  [[13 ,17 , 31 ,25 , 24 ,51 , 61 ,45 ],
155+                [48 ,102 , 119 ,96 , 97 ,189 , 217 ,184 ],
156+                [171 ,384 , 324 ,451 , 616 ,618 , 800 ,800 ]]
157+ 
158+ 
159+ class  YOLOv4P6 (YOLO ):
160+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov4-p6.trt' 
161+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov4-p6.onnx' 
162+     NUM_CLASSES  =  1 
163+     LETTERBOX  =  True 
164+     NEW_COORDS  =  True 
165+     INPUT_SHAPE  =  (3 , 1280 , 1280 )
166+     LAYER_FACTORS  =  [8 , 16 , 32 , 64 ]
167+     SCALES  =  [2.0 , 2.0 , 2.0 , 2.0 ]
168+     ANCHORS  =  [[13 ,17 ,  31 ,25 ,  24 ,51 , 61 ,45 ],
169+                [61 ,45 ,  48 ,102 ,  119 ,96 ,  97 ,189 ],
170+                [97 ,189 ,  217 ,184 ,  171 ,384 ,  324 ,451 ],
171+                [324 ,451 , 545 ,357 , 616 ,618 , 1024 ,1024 ]]
172+ 
173+ 
174+ class  YOLOv4Tiny (YOLO ):
175+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov4-tiny.trt' 
176+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov4-tiny.onnx' 
177+     NUM_CLASSES  =  1 
178+     INPUT_SHAPE  =  (3 , 416 , 416 )
179+     LAYER_FACTORS  =  [32 , 16 ]
180+     SCALES  =  [1.05 , 1.05 ]
181+     ANCHORS  =  [[81 ,82 , 135 ,169 , 344 ,319 ],
182+                [23 ,27 , 37 ,58 , 81 ,82 ]]
183+ 
184+ 
185+ class  YOLOv3 (YOLO ):
186+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov3.trt' 
187+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov3.onnx' 
188+     NUM_CLASSES  =  1 
189+     INPUT_SHAPE  =  (3 , 416 , 416 )
190+     LAYER_FACTORS  =  [32 , 16 , 8 ]
191+     SCALES  =  [1. , 1. ]
192+     ANCHORS  =  [[116 ,90 , 156 ,198 , 373 ,326 ],
193+                [30 ,61 , 62 ,45 , 59 ,119 ],
194+                [10 ,13 , 16 ,30 , 33 ,23 ]]
195+ 
196+ 
197+ class  YOLOv3SPP (YOLO ):
198+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov3-spp.trt' 
199+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov3-spp.onnx' 
200+     NUM_CLASSES  =  1 
201+     INPUT_SHAPE  =  (3 , 608 , 608 )
202+     LAYER_FACTORS  =  [32 , 16 , 8 ]
203+     SCALES  =  [1. , 1. ]
204+     ANCHORS  =  [[116 ,90 , 156 ,198 , 373 ,326 ],
205+                [30 ,61 , 62 ,45 , 59 ,119 ],
206+                [10 ,13 , 16 ,30 , 33 ,23 ]]
207+ 
208+ 
209+ class  YOLOv3Tiny (YOLO ):
210+     ENGINE_PATH  =  Path (__file__ ).parent  /  'yolov3-tiny.trt' 
211+     MODEL_PATH  =  Path (__file__ ).parent  /   'yolov3-tiny.onnx' 
212+     NUM_CLASSES  =  1 
213+     INPUT_SHAPE  =  (3 , 416 , 416 )
214+     LAYER_FACTORS  =  [32 , 16 ]
215+     SCALES  =  [1. , 1. ]
216+     ANCHORS  =  [[81 ,82 , 135 ,169 , 344 ,319 ],
217+                [10 ,14 , 23 ,27 , 37 ,58 ]]
0 commit comments