Onnx pre-trained networks from model zoo not read using readNetFromONNX

I’ve tried to run many vision networks from the Onnx model zoo.
The networks are:

  • caffenet-9_model.onnx
  • fcn-resnet50-11_model.onnx
  • fcn-resnet101-11_model.onnx
  • faster_rcnn_R_50_FPN_1x.onnx
  • ssd_mobilenet_v1.onnx
  • yolov4.onnx
  • mask_rcnn_R_50_FPN_1x.onnx
  • ResNet101_DUC_HDC.onnx
  • retinanet-9.onnx

Only the latter is read and works correctly.
The other networks gives many different errors when readNetFromONNX is called, therefore it’s impossible to call the following steps.
I wasn’t able to find a reason for this in the OpenCV docs and tutorials, or in Onnx site.

Before i issue a bug on OpenCV github, is there someone that knows a reason for this ?

  • Opencv 4.5.3
  • Windows 10
  • C++
  • Qt creator project

i have all the error messages for each of networks listed before.
as an example, for ssd_mobilenet_v1.onnx the error is:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_graph_simplifier.cpp:651: error: (-210:Unsupported format or combination of formats) Unsupported data type: BOOL in function ‘cv::dnn::dnn4_v20210608::getMatFromTensor’

List of error messages for each of networks listed before.

faster_rcnn_R_50_FPN_1x.onnx    

    try-catch:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function “cv::dnn::dnn4_v20210608::ONNXImporter::handleNode” > Node [ConstantOfShape]:(549) parse error: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:1833: error: (-2:Unspecified error) in function “void __cdecl cv::dnn::dnn4_v20210608::ONNXImporter::handleNode(const class opencv_onnx::NodeProto &)” > > (expected: “inpShape[i] > 0”), where > > “inpShape[i]” is 0 > > must be greater than > > “0” is 0 > "

    stderr:

[ERROR:1] global D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [ConstantOfShape]:(549)

ssd_mobilenet_v1.onnx    

    try-catch:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_graph_simplifier.cpp:651: error: (-210:Unsupported format or combination of formats) Unsupported data type: BOOL in function ‘cv::dnn::dnn4_v20210608::getMatFromTensor’

    stderr:

none

yolov4.onnx    

    try-catch:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function “cv::dnn::dnn4_v20210608::ONNXImporter::handleNode” > Node [Log]:(StatefulPartitionedCall/model/lambda/Log:0) parse error: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\dnn.cpp:621: error: (-2:Unspecified error) Can"t create layer “StatefulPartitionedCall/model/lambda/Log:0” of type “Log” in function “cv::dnn::dnn4_v20210608::LayerData::getLayerInstance” >

    stderr:

[ERROR:1] global D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [Log]:(StatefulPartitionedCall/model/lambda/Log:0)

mask_rcnn_R_50_FPN_1x.onnx    

    try-catch:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function “cv::dnn::dnn4_v20210608::ONNXImporter::handleNode” > Node [ConstantOfShape]:(549) parse error: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:1833: error: (-2:Unspecified error) in function “void __cdecl cv::dnn::dnn4_v20210608::ONNXImporter::handleNode(const class opencv_onnx::NodeProto &)” > > (expected: “inpShape[i] > 0”), where > > “inpShape[i]” is 0 > > must be greater than > > “0” is 0 > -"

    stderr:

[ERROR:1] global D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [ConstantOfShape]:(549)

ResNet101_DUC_HDC.onnx    

    try-catch:

OPENCV EXCEPTION: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:2146: error: (-2:Unspecified error) in function “cv::dnn::dnn4_v20210608::ONNXImporter::handleNode” > Node [Sum]:(fc1_cityscapes) parse error: OpenCV(4.5.3) D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp:909: error: (-2:Unspecified error) in function “void __cdecl cv::dnn::dnn4_v20210608::ONNXImporter::handleNode(const class opencv_onnx::NodeProto &)” > > (expected: “node_proto.input_size() == 2”), where > > “node_proto.input_size()” is 4 > > must be equal to > > “2” is 2 > "

    stderr:

[ERROR:1] global D:\3rdParty\OpenCV\opencv-4.5.3\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 4 inputs and 1 outputs: [Sum]:(fc1_cityscapes)