Skip to content

Failed to load custom ONNX model #17848

@Quantizs

Description

@Quantizs
System information (version)
  • OpenCV => 4.4.0 pre
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2019
Detailed description

We have a custom ONNX model wich can be load and inference with opencv 4.1.1 but currently can not do it with opencv 4.4.0 pre. We received the error below:

OpenCV(4.4.0-pre) D:\opencv-master\modules\dnn\src\graph_simplifier.cpp:79: error: (-212:Parsing error) Input node with name StatefulPartitionedCall/sequential/dense/MatMul not found in function 'cv::dnn::Subgraph::getInputNodeId'

the network structure is:

keras.layers.Conv2D(128,(5,5),input_shape=(height,width,1)),
    keras.layers.MaxPooling2D(pool_size=(2,2)),
    keras.layers.Dropout(0.49),
    keras.layers.Conv2D(64,(5,5)),
    keras.layers.MaxPooling2D(pool_size=(2,2)),
    keras.layers.Dropout(0.49),
    keras.layers.Flatten(),
    keras.layers.Dense(64, activation='relu'),
    keras.layers.Dense(64, activation='relu'),
    keras.layers.Flatten(),
    keras.layers.Dropout(0.45),
    keras.layers.Dense(36, activation='softmax')

The model is saved as TF saved_model and exported to ONNX with tf2onnx package.

Steps to reproduce

The model can be downloaded from here:
ONNX model

I try to load it with cv::dnn::readNetFromONNX but it cause the error above altough it was successfully loaded with previous opencv version (4.1.1).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions