TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

对Yolov8n.pt转wts后,再序列化构建时,addResize()函数返回值为空,应如何解决?

Open retioa11 opened this issue 1 year ago • 8 comments

### Tasks

retioa11 avatar Jun 24 '24 07:06 retioa11

想把这个仓库的代码,[https://github.com/wang-xinyu/tensorrtx/tree/master/yolov8,修改为支持推理时动态形状,如下图的红框所示: 571438db915696590cc3d782eb1920c 修改了红框里的三四行代码,第100行就返回为空了,该如何解决呢?

retioa11 avatar Jun 24 '24 07:06 retioa11

You can upload the code for the two versions before and after here. @retioa11

lix19937 avatar Jun 25 '24 10:06 lix19937

You can upload the code for the two versions before and after here. @retioa11 different: image code for the two versions before and after: [ yolov8_before.zip ](url) yolov8_after.zip before: 0a641c46eca4da4fe86400be76eedb3 after: f746d3eab81ea9e59e0991ae8e2bc6f

retioa11 avatar Jun 28 '24 08:06 retioa11

Are your H,W are dynamic shape ?

If H W are dynamic shape, you can ref https://github.com/lix19937/trt-samples-for-hackathon-cn/blob/master/cookbook/02-API/OptimizationProfile/main-TensorInput.py#L28

lix19937 avatar Jun 29 '24 03:06 lix19937

Oh, thank you. But wondering why my modification is returned empty and how should be modified to serialize Yolov8. Does the code in the link help? Not very understand.

retioa11 avatar Jun 30 '24 02:06 retioa11

If you use dynamic shape, you should set dynamic binding's shape at each infer.
Like https://github.com/lix19937/trt-samples-for-hackathon-cn/blob/master/cookbook/02-API/OptimizationProfile/main-TensorInput.py#L50
and
https://github.com/NVIDIA/TensorRT/blob/release/10.1/samples/sampleDynamicReshape/sampleDynamicReshape.cpp#L428-L432

lix19937 avatar Jun 30 '24 03:06 lix19937

As usual, it's caused by not setting the right dynamic shape profile or rt-input shapes.

lix19937 avatar Jul 03 '24 01:07 lix19937

Thanks, I'll have it a try。

retioa11 avatar Jul 29 '24 02:07 retioa11

Closing this issue for now but feel free to reopen if you still see the problem!

poweiw avatar Feb 11 '25 22:02 poweiw