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

**URL:** https://forum.opencv.org/t/onnx-pre-trained-networks-from-model-zoo-not-read-using-readnetfromonnx/5040
**Category:** Uncategorized
**Tags:** dnn
**Created:** [September 3, 2021, 8:23am UTC](https://forum.opencv.org/t/onnx-pre-trained-networks-from-model-zoo-not-read-using-readnetfromonnx/5040 "2021-09-03T08:23:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![benedetto\_michelozzi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/benedetto_michelozzi/32/2670_2.png) [@benedetto\_michelozzi](https://forum.opencv.org/u/benedetto_michelozzi)
#### Post date: [September 3, 2021, 8:23am UTC](https://forum.opencv.org/t/onnx-pre-trained-networks-from-model-zoo-not-read-using-readnetfromonnx/5040/1 "2021-09-03T08:23:26Z")

</div>

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’

---

<div class="post-metadata">

### Author: ![benedetto\_michelozzi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/benedetto_michelozzi/32/2670_2.png) [@benedetto\_michelozzi](https://forum.opencv.org/u/benedetto_michelozzi)
#### Post date: [September 6, 2021, 1:19pm UTC](https://forum.opencv.org/t/onnx-pre-trained-networks-from-model-zoo-not-read-using-readnetfromonnx/5040/3 "2021-09-06T13:19:00Z")

</div>

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)
