Skip to content

Opencv ONNX MaxPool1d Throws error: (-215:Assertion failed) attribute_proto.ints_size() == 2 || attribute_proto.ints_size() == 3 in function 'getLayerParams' #18643

@anilsathyan7

Description

@anilsathyan7

OpenCV => 4.5
Operating System / Platform => Ubuntu 18.04
Compiler => gcc
Detailed description
When I load the onnx model (converted from pytorch ) using cv::dnn::readNetFromONNX, it throws error:

[ERROR:0] global /home/anilsathyan7/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp (1788) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [MaxPool]:(776)
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.0) /home/anilsathyan7/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp:1797: error: (-2:Unspecified error) in function 'handleNode'

Node [MaxPool]:(776) parse error: OpenCV(4.5.0) /home/anilsathyan7/opencv-4.5.0/modules/dnn/src/onnx/onnx_importer.cpp:203: error: (-215:Assertion failed) attribute_proto.ints_size() == 2 || attribute_proto.ints_size() == 3 in function 'getLayerParams'

Aborted (core dumped)

However i'am able to run the onnx models using onnxruntime inference session and pytorch without any problems. Also i was able to load the mobilenetv2 model using the same setup.

Sample Code:-

//Parameters
String model = "SINet9.onnx";
int backendId = 0; // Auto
int targetId = 0;  // CPU
int inpWidth = 320;
int inpHeight = 320;

// Read network
CV_Assert(!model.empty());

Net net = readNetFromONNX(model);//readNet(model, config, framework);
net.setPreferableBackend(backendId);
net.setPreferableTarget(targetId);

Models:-
SINet9.zip

Netron:-
maxpool

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions