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'
System information (version)
Detailed description
similar issues have been reported (and have been resolved) for tensorflow (#10739 , #15822) and yolo(#11310, #16831)
Steps to reproduce
exported onnx can be checked from here
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution