"Unknown shape for input tensor[tensor name: '{}'] -> shape: {}, Please define shape of input here,\nNote:you can use visualization tools like Netron to check input shape."
.format(vi.name,shape))
right_shape_been_input=False
whilenotright_shape_been_input:
try:
shape=raw_input(
"Shape of Input(e.g. -1,3,224,224), enter 'N' to skip: "
)
except:
shape=input(
"Shape of Input(e.g. -1,3,224,224), enter 'N' to skip: "
)
ifshape.count("-1")>1:
print("Only 1 dimension can be -1, type again:)")
else:
right_shape_been_input=True
ifshape=='N':
break
shape=[int(dim)fordiminshape.strip().split(',')]
assertshape.count(-1)<=1,"Only one dimension can be -1"
'During conversion of your model, some operators will be assignd node.out_shape==None, '
'refer to https://github.com/onnx/onnx/blob/master/docs/ShapeInference.md'
)
try:
datatype_map={
'tensor(int64)':'int',
'tensor(float)':'float32',
'tensor(int32)':'int32'
}
input_dict={}
sess=rt.InferenceSession(model_path)
foriptinsess.get_inputs():
datatype=datatype_map[ipt.type]
input_dict[ipt.name]=np.random.random(
ipt.shape).astype(datatype)
res=sess.run(None,input_feed=input_dict)
except:
raiseException(
"onnxruntime inference onnx model failed, Please confirm the correctness of onnx model by onnxruntime, if onnx model is correct, please submit issue in github."