zheshipinyinMc / arcface_retinaface_mxnet2onnx

arcface and retinaface model convert mxnet to onnx.
59 stars 19 forks source link

MXNetError: Error in operator pre_fc1: Shape inconsistent #17

Open vio938 opened 1 year ago

vio938 commented 1 year ago

Got an error when I try mxnet2onnx

Traceback (most recent call last): File "mxnet2onnx_demo.py", line 73, in mxnet2onnx_test() #==mxnet2onnx File "mxnet2onnx_demo.py", line 25, in mxnet2onnx_test converted_model_path = onnx_mxnet.export_model(sym, params, input_shape, np.float32, onnx_file) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/contrib/onnx/init.py", line 53, in export_model return exportmodel(args, kwargs) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_model.py", line 125, in export_model dynamic=dynamic, dynamic_input_shapes=dynamic_input_shapes) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_onnx.py", line 298, in create_onnx_graph_proto in_types, dynamic, dynamic_input_shapes) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/onnx/mx2onnx/_export_onnx.py", line 190, in getoutputs , outshapes, = sym.infer_shape(inputs) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/symbol/symbol.py", line 1101, in infer_shape res = self._infer_shape_impl(False, args, **kwargs) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/symbol/symbol.py", line 1265, in _infer_shape_impl ctypes.byref(complete))) File "/hhdxx2/wzq/venv/lib/python3.6/site-packages/mxnet/base.py", line 246, in check_call raise get_last_ffi_error() mxnet.base.MXNetError: MXNetError: Error in operator pre_fc1: Shape inconsistent, Provided = [512,25088], inferred shape=(512,819200)

Code:

def mxnet2onnx_test(): sym = './model/model-symbol.json' params = './model/model-0000.params' input_shape = [(1,3,640,640)] onnx_file = './model/model-0000.onnx'
converted_model_path = onnx_mxnet.export_model(sym, params, input_shape, np.float32, onnx_file)

Check the model

onnx.checker.check_model(onnx_file) print('The model is checked!') if name == 'main':
mxnet2onnx_test() #==mxnet2onnx

Can anyone help me with this issue?