ThanatosShinji / onnx-tool

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

About an issue encountered in running the command line "python -m onnx_tool ......" #83

Open xwentian2020 opened 2 weeks ago

xwentian2020 commented 2 weeks ago

Describe the bug In running the command line "python -m onnx_tool -i 'resnet50-v1-12.onnx' -o 'resnet50_shapes.onnx'", the info promoted there was something unexpected, listed as follows.

PS H:\AIModels> python -m onnx_tool -i 'resnet50-v1-12.onnx' -o 'resnet50_shapes.onnx' Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "G:\onnx-tool\sd_env\Lib\site-packages\onnx_tool__main__.py", line 93, in onnx_tool.modelprofile(args.in, dynamic, save_profile=args.file, save_model=args.out) File "G:\onnx-tool\sd_env\Lib\site-packages\onnx_tool__init__.py", line 84, in model_profile g.shape_infer(dynamic_shapes) File "G:\onnx-tool\sd_env\Lib\site-packages\onnx_tool\graph.py", line 974, in shape_infer raise ValueError( ValueError: The input tensor data's shape [N,3,224,224] is not valid, Please set it to a valid shape.

Any suggestions for solving the above issue?

xwentian2020 commented 2 weeks ago

The model used in the above command line can be found in https://hf-mirror.com/webai-community/models/tree/main. The Python libs installer are as follows.

PS H:\AIModels> pip list -v
Package    Version Location                              Installer
---------- ------- ------------------------------------- ---------
numpy      1.26.4  G:\onnx-tool\sd_env\Lib\site-packages pip      
onnx       1.16.1  G:\onnx-tool\sd_env\Lib\site-packages pip      
onnx-tool  0.9.0   G:\onnx-tool\sd_env\Lib\site-packages pip      
pip        24.0    G:\onnx-tool\sd_env\Lib\site-packages pip      
protobuf   5.27.1  G:\onnx-tool\sd_env\Lib\site-packages pip      
setuptools 65.5.0  G:\onnx-tool\sd_env\Lib\site-packages pip      
tabulate   0.9.0   G:\onnx-tool\sd_env\Lib\site-packages pip    
ThanatosShinji commented 2 weeks ago

ValueError: The input tensor data's shape [N,3,224,224] is not valid, Please set it to a valid shape.

you should specify a fixed input shape for your model