Skip to content

dnn: Inconsistent shape for ConcatLayer in function 'getMemoryShapes' from onnx #18350

@berak

Description

@berak
System information (version)
  • OpenCV => 4.4.0-dev
  • Operating System / Platform => colab
  • Compiler => python 3.8
Detailed description

similar issues have been reported (and have been resolved) for tensorflow (#10739 , #15822) and yolo(#11310, #16831)

Steps to reproduce
git clone https://github.com/berak/VNL_Monocular_Depth_Prediction
wget https://cloudstor.aarnet.edu.au/plus/s/7kdsKYchLdTi53p/download -O ResNext101_32x4d_NYU.pth

import cv2
import torch
import numpy as np
from lib.models.metric_depth_model import MetricDepthModel

def load_ckpt(fn, model, optimizer=None, scheduler=None, val_err=[]):
    checkpoint = torch.load(fn, map_location=lambda storage, loc: storage)
    model.load_state_dict(checkpoint['model_state_dict'])
 
model = MetricDepthModel()
model.eval()
load_ckpt("/content/VNL_Monocular_Depth_Prediction/ResNext101_32x4d_NYU.pth", model)

def convert_to_onnx(net, output_name):
    input = {'A':torch.randn(1,3,240,320)}
    input_names = ['data']
    output_names = ['output']
    net.eval()
    torch.onnx.export(net, input, output_name, verbose=True, input_names=input_names, output_names=output_names, opset_version=11)
model.cuda()
convert_to_onnx(model, "VNL.onnx")

import cv2
cv2.dnn.readNet("VNL.onnx")
error: OpenCV(4.4.0-dev) /content/opencv/modules/dnn/src/layers/concat_layer.cpp:102: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'getMemoryShapes'

exported onnx can be checked from here

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions