Hi,
I can successfully create TRT engine from yolov4 onnx model containing BatchedNMSDynamic plugin. I add this plugin by this script. Now I want to use BatchedNMS plugin for static batch size instead of BatchedNMSDynamic to compare them in terms of speed. According the docs, both plugins have the same outputs and these are num_detections, nmsed_boxes, nmsed_scores and nmsed_classes.
The creation of the TRT engine from onnx model containing BatchedNMS plugin by trtexec is ok, but when I try to use it in the Deepstream pipeline, it gives me following error:
I do not know why num_detections is 0. Only what I found from trtexec logs, that both TRT engines have different dimension for num_detections outputs:
Logs from trtexec during creation of TRT model with BatchedNMS plugin:
input 8x3x544x544 num_detections with dimensions 8
nmsed_boxes with dimensions 8x1000x4
nmsed_scores with dimensions 8x1000
nmsed_classes with dimensions 8x1000
Logs from trtexec during creation of TRT model with BatchedNMSDynamic plugin:
input 8x3x544x544 num_detections with dimensions 8x1
nmsed_boxes with dimensions 8x1000x4
nmsed_scores with dimensions 8x1000
nmsed_classes with dimensions 8x1000
And it is weird!
I also checked both onnx models containing BatchedNMS plugin and BatchedNMSDynamic plugin with Netron and the outputs of both models are completely same.
Onnx model with BatchedNMS plugin:
Onnx model with BatchedNMSDynamic plugin:
It seems to me like a bug in the BatchedNMS. Do you have any idea?
Hitting this EXACT same problem when on TRT 8.0.1, Jetpack 4.6, DeepStream 6.0.
When placing a BatchedNMS head on a Yolov5 model DeepStream fails to start (showing 0 dimension for num_detections). When using a DynamicBatchedNMS head, everything runs and loads great.
I ran on the DS deepstream_test1_rtsp_out.py app. I compiled the attached models with trtexec I wrote my own custom parser which is irrelevant to this issue as the DS app crashes during the loading of the model in the nvinfer plugin (before the parser is even envoked). Attached below are 3 model ONNX files. I know theyre not exactly the same model, but they demonstrate the issue:
yoloxN_dynamic_640.onnx - Original model.
yoloxS_640_batched_nms_dynamic.onnx - DynamicBatchedNMS model. WORKS
yoloxN_dynamic_640_batched_nms_bs1.onnx - BatchedNMS model. FAILS
Example of the error I am seeing (not specifically for the models here, but for any static BatchedNMS):
Hi @mchi , Here is zip file containing models. There is official yolov4-csp weight with config file taken from https://github.com/AlexeyAB/darknet repo. The weight and the config file were used to generate onnx models.
To generate onnx model from Darknet weight and config, I used this repo.
To add both plugins (BatchedNMSDynamic_TRT, BatchedNMS_TRT) I used this script.
To generate engine mode, the trtexec was used.
In dynamic_nms_batched folder there are onnx and engine models with BatchedNMSDynamic_TRT plugin. You can run it with deepstream-app, it works.
In static_nms_batched folder there are onnx and engine models with BatchedNMS_TRT plugin. This engine model does not work and it throws the known error (you can try by deepstream-app):
Ok, I did it again and now the models have the same FPS (around 4 * 130FPS). It was probably caused by wrong version of tensorrt (my version is 8.0 and I put there TensorRT OSS version of 8.2).