opencv: onnx 12: Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'
I’m working on a Unet model and the upsampling layers will trigger an exception when infering on an image with a different size than the training dataset: Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'
When exporting to onnx opset 9, inference work for any input size. The upsampling layer is defined as Upsample
When exporting to onnx opset >9, inference work on 256² only. The upsampling layer is defined as Resize
I can provide both onnx by email if needed
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (22 by maintainers)
Commits related to this issue
- Fixing dnn Resize layer for variable input size Work in progress for #18695 — committed to JulienMaille/opencv by JulienMaille 4 years ago
- add new test models for Resize layer https://github.com/opencv/opencv/issues/18695 — committed to JulienMaille/opencv_extra by JulienMaille 4 years ago
- Fixing dnn Resize layer for variable input size Work in progress for #18695 — committed to JulienMaille/opencv by JulienMaille 4 years ago
- Fixing dnn Resize layer for variable input size Work in progress for #18695 — committed to JulienMaille/opencv by JulienMaille 4 years ago
- add new test models for Resize layer https://github.com/opencv/opencv/issues/18695 — committed to JulienMaille/opencv_extra by JulienMaille 4 years ago
- add new test models for Resize layer https://github.com/opencv/opencv/issues/18695 — committed to JulienMaille/opencv_extra by JulienMaille 4 years ago
- add new test models for Resize layer https://github.com/opencv/opencv/issues/18695 — committed to JulienMaille/opencv_extra by JulienMaille 4 years ago
- add new test models for Resize layer https://github.com/opencv/opencv/issues/18695 — committed to JulienMaille/opencv_extra by JulienMaille 4 years ago
Ok so I exported both models with different opset, this is what I got
So I could change my PR to this:
@JulienMaille Please use this script used for generation of .onnx test files: https://github.com/opencv/opencv_extra/blob/4.5.0/testdata/dnn/onnx/generate_onnx_models.py
Yes, I think it’s easier to understand. But you need a change:
I confirm that editing my onnx and adding “zoom_factor_x”, “zoom_factor_y” will make it work. So what we would need is to read from scales input instead
EDIT: which seems to be done here: https://github.com/opencv/opencv/blob/199687a1c5b194481754d3efe14cb06a82efa805/modules/dnn/src/onnx/onnx_importer.cpp#L1689-L1700