2

I'm working on model inference using opencv cuda dnn module. While reading my onnx file using cv::dnn:: readNetFromONNX, I'm getting below message.

Opencv(4.4.0-dev) Error: Unspecified error (> (expected: 'shape.depth() == CV_32S') where 'shapes.depth()' is 5 (CV_32FC1) must be equal to 'CV_32S' is 4 (CV_32SC1) in void_cdecl cv::dnn::dnn4_v20200609::ONNXImporter::populateNet(class cv::dnn::dnn4_v20200609::Net), file D:\opencv_test\newbuild\opencv-master\modules\dnn\src\onnx\innx_importer.cpp, line 1442

What could be the reason for this? If someone faced the similar issue and find any solution, please let me know. Thanks in advance.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

2 Answers2

1

Your input blob type must be CV_32SC1 (int) not CV_32FC1 (float).

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • Thanks for your response. Actually I'm getting above error at 'readNetFromONNX()' api call. Below url is the code ,I used but readNetFromONNX is used instead of using 'readNet' as I'm reading .onnx extension file.https://docs.opencv.org/3.4/d9/d8d/samples_2dnn_2classification_8cpp-example.html#a15 – eLtronicsvilla Sep 05 '20 at 19:28
  • You can check the model and blob types with https://github.com/lutzroeder/netron tool. Or put your model here, so I could try to help you. – Andrey Smorodov Sep 06 '20 at 06:28
  • Sorry, Due to some restrictions I'm not able to provide my onnx file . So I did some experiment. Actually this onnx model converted for SegNet architecture. What I observed is this 'upsampling layer' present in network architecture is creating the issue. I'm able to read onnx file without upsampling layer. Is upsampling layer is supported in Opencv dnn? – eLtronicsvilla Sep 16 '20 at 09:27
  • 1
    This issue is fixed by using conv2DTranspose in the place of Upsampling2D api for SegNet network architecture layer. Thanks. – eLtronicsvilla Sep 18 '20 at 17:00
  • Can you please answer this question https://stackoverflow.com/questions/69633595/load-onnx-model-in-opencv-dnn – fisakhan Oct 21 '21 at 12:00
1

Opencv 4.5+ should solve the issue for me 4.5.1.48 worked.