daquexian / onnx-simplifier

Simplify your onnx model
Apache License 2.0
3.84k stars 383 forks source link

The shape of input "input" has dynamic size, please determine the input size manually by --input-shape xxx #87

Open xinsuinizhuan opened 4 years ago

xinsuinizhuan commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

Model To reproduce the problem, please post download link of your model here, or send your model to daquexian566@gmail.com when i run it, it error: E:\ProgramData\Anaconda3\envs\base37\python.exe I:/NCNN/ncnn/tencent_ncnn/onnx-simplifier-master/onnxsim/main.py I:\OCR\chineseocr_lite-onnx\models\crnn_lstm.onnx I:\OCR\chineseocr_lite-onnx\models\crnn_lstm_ex.onnx Simplifying... Traceback (most recent call last): File "I:/NCNN/ncnn/tencent_ncnn/onnx-simplifier-master/onnxsim/main.py", line 52, in main() File "I:/NCNN/ncnn/tencent_ncnn/onnx-simplifier-master/onnxsim/main.py", line 40, in main args.input_model, check_n=args.check_n, perform_optimization=not args.skip_optimization, skip_fuse_bn=not args.enable_fuse_bn, input_shapes=input_shapes, skipped_optimizers=args.skip_optimizer, skip_shape_inference=args.skip_shape_inference) File "I:\NCNN\ncnn\tencent_ncnn\onnx-simplifier-master\onnxsim\onnx_simplifier.py", line 331, in simplify model, const_nodes, input_shapes=input_shapes) File "I:\NCNN\ncnn\tencent_ncnn\onnx-simplifier-master\onnxsim\onnx_simplifier.py", line 172, in forward_for_node_outputs res = forward(model, input_shapes=input_shapes) File "I:\NCNN\ncnn\tencent_ncnn\onnx-simplifier-master\onnxsim\onnx_simplifier.py", line 157, in forward inputs = generate_rand_input(model, input_shapes=input_shapes) File "I:\NCNN\ncnn\tencent_ncnn\onnx-simplifier-master\onnxsim\onnx_simplifier.py", line 108, in generate_rand_input 'please determine the input size manually by --input-shape xxx'.format(key)) RuntimeError: The shape of input "input" has dynamic size, please determine the input size manually by --input-shape xxx

Process finished with exit code 1

xinsuinizhuan commented 4 years ago

I convert the https://github.com/ouyanghuiyu/chineseocr_lite/tree/onnx model, crnn_lstm to ncnn.But so many op do not support, i use the onnx-simplifier to convert it ,firstly, but it break some error, as befor.

Cookies1996 commented 3 years ago

use netron see your input ,and use python -m onnxsim your.onnx yoursimp.onnx --input-shape input_0:1,800,800,3 input_1:1,800,800,3 input_2:1,800,800,3 ....input_n:1,800,800,3(800 is my input image size,mobilenet)

shopping-tang commented 3 years ago

model_simp, check = simplify(model, input_shapes={"images:0":(1, 128, 64, 3)})