ThanatosShinji / onnx-tool

A parser, editor and profiler tool for ONNX models.
https://pypi.org/project/onnx-tool/
MIT License
399 stars 52 forks source link

when I profiles yolop.onnx It has problem #5

Closed Arche-Logos closed 2 years ago

Arche-Logos commented 2 years ago

modelpath = "yolop-1280-1280.onnx"

inputs = {'image:0': create_ndarray_f32((1,3,1280,1280))}

onnx_tool.model_profile(modelpath, inputs, None)

Traceback (most recent call last): File "onnxAnalyze.py", line 11, in onnx_tool.model_profile(modelpath, inputs, None) # save profile table to csv file File "onnx_tool__init.py", line 258, in model_profile graph_profile(m.graph, dynamic_shapes, verbose, hidden_ops=hidden_ops) File "onnx_tool\init.py", line 147, in graph_profile tmap, pmap = infer_shapes(graph, dynamic_shapes, verbose=verbose) File "nnx_tool\init__.py", line 115, in infer_shapes outtensors = node_infer_shape(node, ins) File "onnx_tool\node_profilers.py", line 1498, in node_infer_shape return profler.infer_shape(ins) File "onnx_tool\node_profilers.py", line 222, in infer_shape return [intensors[0] + intensors[1]] ValueError: operands could not be broadcast together with shapes (1,3,160,160,6) (1,1,160,160,2)

ThanatosShinji commented 2 years ago

seems something is wrong with this model's shape inference. Can you share this model with me?

Arche-Logos commented 2 years ago

seems something is wrong with this model's shape inference. Can you share this model with me? Baidu Drive code: 8gin model is yolop.onnx. and I find when I set the siput such as "inputs = {'images:0': create_ndarray_f32((1, 3, 125, 414))}" it not used.

ThanatosShinji commented 2 years ago

and I find when I set the siput such as "inputs = {'images:0': create_ndarray_f32((1, 3, 125, 414))}" it not used.

you set the input tensor name as 'images:0', but I think it's 'images' from 'yolop-1280-1280.onnx'

ThanatosShinji commented 2 years ago

ValueError: operands could not be broadcast together with shapes (1,3,160,160,6) (1,1,160,160,2)

the bug has been fixed in v0.2.11.

inputs = {'images:0': create_ndarray_f32((1, 3, 125, 414))}

this input shape is not valid for yolop, it requires H&W are padded to 32, you should try (1,3,128,416). On the other hand your model yolop-1280-1280.onnx is a fixed input shape model, which means the input shape can only be (1,3,1280,1280)