itsnine / yolov5-onnxruntime

YOLOv5 ONNX Runtime C++ inference code.
246 stars 58 forks source link

Dynamic input shape #12

Closed emanef13 closed 2 years ago

emanef13 commented 2 years ago

There seem to be an issue handling an input other than 640x640. When I try to feed a 320x1296 input it throws an error: Got invalid dimensions for input: images for the following indices index: 2 Got: 1296 Expected: 640 index: 3 Got: 320 Expected: 640

I think it has to do with the dynamic input shape checking of the code, which I think it is not doing its job correctly. Can someone point me where should I look at, to make it able to excecute multiple input shape images? Thanks!

emanef13 commented 2 years ago

Issue solved. I had to export the model again through ultralitics with the --dynamic option.

itsnine commented 2 years ago

@emanef13 I'm glad you found the solution, also it has to print about dynamic shape in the terminal if it is detected in the onnx model, here is the code doing that https://github.com/itsnine/yolov5-onnxruntime/blob/8d553dea971c6c44c3aa00f2ef1291ef5bd4411b/src/detector.cpp#L42-L46