jakeret/unet

Load Unet model in OpenCV?

kretep opened this issue · 3 comments

I'm trying to load a saved Unet model in OpenCV using dnn.readNetFromTensorflow and dnn.readNetFromONNX, but both methods are failing. The first one hangs and the second results in an obscure error.

> Node [Slice@ai.onnx]:(onnx_node!StatefulPartitionedCall/unet/crop_concat_block/strided_slice_6) parse error: OpenCV(4.6.0) /Users/xperience/actions-runner/_work/opencv-python/opencv-python/opencv/modules/dnn/src/onnx/onnx_importer.cpp:1345: error: (-215:Assertion failed) axes[i - 1] == axes[i] - 1 in function 'parseSlice'

Has anyone done this before?

I haven't tried this before and I'm also unsure why it doesn't work. The CropConcatBlock is not doing anything special.

You could try to change the slicing of the down_layer. The last : is in principle not need

Thanks for your reply. Changing the slicing didn't help.

I dived into it a bit further and the issue seems to be in OpenCV. It looks like slicing is not properly processed in some cases: issue. It's already fixed, but not in a release yet. It works after building the dev version of OpenCV.

Thank you for digging into this. Hopefully it will be released soon