@@ -89,7 +89,6 @@ See following sections for more details of conversions.
8989| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |
9090| DarkNet (YOLOv4 paper)| 0.471 | 0.710 | 0.510 | 0.278 | 0.525 | 0.636 |
9191| Pytorch (TianXiaomo)| 0.466 | 0.704 | 0.505 | 0.267 | 0.524 | 0.629 |
92- | ONNX | incoming | incoming | incoming | incoming | incoming | incoming |
9392| TensorRT FP32 + BatchedNMSPlugin | 0.472| 0.708 | 0.511 | 0.273 | 0.530 | 0.637 |
9493| TensorRT FP16 + BatchedNMSPlugin | 0.472| 0.708 | 0.511 | 0.273 | 0.530 | 0.636 |
9594
@@ -99,7 +98,6 @@ See following sections for more details of conversions.
9998| ------------------- | ----------: | ----------: | ----------: | ----------: | ----------: | ----------: |
10099| DarkNet (YOLOv4 paper)| 0.412 | 0.628 | 0.443 | 0.204 | 0.444 | 0.560 |
101100| Pytorch (TianXiaomo)| 0.404 | 0.615 | 0.436 | 0.196 | 0.438 | 0.552 |
102- | ONNX | incoming | incoming | incoming | incoming | incoming | incoming |
103101| TensorRT FP32 + BatchedNMSPlugin | 0.412| 0.625 | 0.445 | 0.200 | 0.446 | 0.564 |
104102| TensorRT FP16 + BatchedNMSPlugin | 0.412| 0.625 | 0.445 | 0.200 | 0.446 | 0.563 |
105103
@@ -163,10 +161,11 @@ Until now, still a small piece of post-processing including NMS is required. We
163161 python demo_darknet2onnx.py < cfgFile> < weightFile> < imageFile> < batchSize>
164162 ` ` `
165163
166- This script will generate 2 ONNX models.
164+ # # 3.1 Dynamic or static batch size
167165
168- - One is for running the demo (batch_size=1)
169- - The other one is what you want to generate (batch_size=batchSize)
166+ - ** Positive batch size will generate ONNX model of static batch size, otherwise, batch size will be dynamic**
167+ - Dynamic batch size will generate only one ONNX model
168+ - Static batch size will generate 2 ONNX models, one is for running the demo (batch_size=1)
170169
171170# 4. Pytorch2ONNX (Evolving)
172171
@@ -195,34 +194,54 @@ Until now, still a small piece of post-processing including NMS is required. We
195194 python demo_pytorch2onnx.py yolov4.pth dog.jpg 8 80 416 416
196195 ` ` `
197196
198- This script will generate 2 ONNX models.
197+ # # 4.1 Dynamic or static batch size
199198
200- - One is for running the demo (batch_size=1)
201- - The other one is what you want to generate (batch_size=batch_size)
199+ - ** Positive batch size will generate ONNX model of static batch size, otherwise, batch size will be dynamic**
200+ - Dynamic batch size will generate only one ONNX model
201+ - Static batch size will generate 2 ONNX models, one is for running the demo (batch_size=1)
202202
203203
204204# 5. ONNX2TensorRT (Evolving)
205205
206206- ** TensorRT version Recommended: 7.0, 7.1**
207207
208+ # # 5.1 Convert from ONNX of static Batch size
209+
208210- ** Run the following command to convert VOLOv4 ONNX model into TensorRT engine**
209211
210212 ` ` ` sh
211213 trtexec --onnx=< onnx_file> --explicitBatch --saveEngine=< tensorRT_engine_file> --workspace=< size_in_megabytes> --fp16
212214 ` ` `
213215 - Note: If you want to use int8 mode in conversion, extra int8 calibration is needed.
214216
215- - ** Run the demo**
217+ # # 5.2 Convert from ONNX of dynamic Batch size
218+
219+ - ** Run the following command to convert VOLOv4 ONNX model into TensorRT engine**
216220
217221 ` ` ` sh
218- python demo_trt.py < tensorRT_engine_file> < input_image> < input_H> < input_W>
222+ trtexec --onnx=< onnx_file> \
223+ --minShapes=input:< shape_of_min_batch> --optShapes=input:< shape_of_opt_batch> --maxShapes=input:< shape_of_max_batch> \
224+ --workspace=< size_in_megabytes> --saveEngine=yolov4_-1_3_320_512_dyna.engine --fp16
219225 ` ` `
226+ - For example:
227+
228+ ` ` ` sh
229+ trtexec --onnx=yolov4_-1_3_320_512_dynamic.onnx \
230+ --minShapes=input:1x3x320x512 --optShapes=input:4x3x320x512 --maxShapes=input:8x3x320x512 \
231+ --workspace=2048 --saveEngine=yolov4_-1_3_320_512_dynamic.engine --fp16
232+ ` ` `
233+
234+ # # 5.3 Run the demo
235+
236+ ` ` ` sh
237+ python demo_trt.py < tensorRT_engine_file> < input_image> < input_H> < input_W>
238+ ` ` `
220239
221- - This demo here only works when batchSize=1, but you can update this demo a little for batched inputs .
240+ - This demo here only works when batchSize is dynamic (1 should be within dynamic range) or batchSize =1, but you can update this demo a little for other dynamic or static batch sizes .
222241
223- - Note1: input_H and input_W should agree with the input size in the original ONNX file.
242+ - Note1: input_H and input_W should agree with the input size in the original ONNX file.
224243
225- - Note2: extra NMS operations are needed for the tensorRT output. This demo uses python NMS code from ` tool/utils.py` .
244+ - Note2: extra NMS operations are needed for the tensorRT output. This demo uses python NMS code from ` tool/utils.py` .
226245
227246
228247# 6. ONNX2Tensorflow
0 commit comments