murdockhou / Yet-Another-EfficientDet-Pytorch-Convert-ONNX-TVM

GNU Lesser General Public License v3.0
59 stars 17 forks source link

onnxruntime推理出错 #4

Open youwh-PIRI opened 4 years ago

youwh-PIRI commented 4 years ago

Hello, this error occurred when I was reasoning on onnxruntime. Have you ever encountered it?Thank you very much if you can reply!

onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from /home/youwh/ywh/efficientDet--ONNX/convert/efficientdet-d1-voc.onnx failed:This is an invalid model. Error in Node: : Node () has input size 1 not in range [min=2, max=3].

murdockhou commented 4 years ago

@youwh-PIRI Sorry for not familiar with onnxruntime.

mychina75 commented 4 years ago

yes. when I try to use onnx-simplifier. The same error occurred. looks like onnx checker can not accept current model format. ################ python -m onnxsim efficientdet-d1.onnx efficientdet-d1-opt.onnx Simplifying... Traceback (most recent call last): File "/opt/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/opt/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/opt/anaconda3/lib/python3.6/site-packages/onnxsim/main.py", line 48, in main() File "/opt/anaconda3/lib/python3.6/site-packages/onnxsim/main.py", line 36, 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) File "/opt/anaconda3/lib/python3.6/site-packages/onnxsim/onnx_simplifier.py", line 301, in simplify onnx.checker.check_model(model) File "/opt/anaconda3/lib/python3.6/site-packages/onnx/checker.py", line 91, in check_model C.check_model(model.SerializeToString()) onnx.onnx_cpp2py_export.checker.ValidationError: Node () has input size 1 not in range [min=2, max=3].

==> Context: Bad node spec: input: "data" output: "1005" op_type: "Pad" attribute { name: "mode" s: "constant" type: STRING } attribute { name: "pads" ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 ints: 1 ints: 1 type: INTS } attribute { name: "value" f: 0 type: FLOAT }

absorbguo commented 3 years ago

I also came across with the "Invalid Feed" error, here is my solution, before testing with onnxruntime_test, I use onnx optimize the onnx model, after "eliminate_unused_initializer" optimization, the onnxruntime_test passed. Hope this solution is usefull for you.

import onnx
from onnx import optimizer
def opt(original_model):
    op = ["eliminate_unused_initializer"]
    optimized_model = optimizer.optimize(original_model, op)
    onnx.save(optimized_model, "efficientdet-d0-opt.onnx")