onnx model 导出

有没有api能吧gluon model_zoo的好模式转换成onnx格式的呢
比如net = gluon.model_zoo.vision.get_model(name, **kwargs)
转换成了net ,但是导出onnx的函数mxnet.contrib.onnx.export_model
export_model(sym, params, input_shape, input_type=np.float32,onnx_file_path=‘model.onnx’, verbose=False):
是这样的,有没有比较简单的方法来转换呢

from gluoncv import model_zoo, utils, data
import mxnet as mx
from mxnet import nd
import numpy as np

mx_model = ‘yolo3_darknet53_coco’
mx_model_root = ‘mx_model/’

onnx_model_root = ‘onnx_model/’

net = model_zoo.get_model(mx_model, pretrained=True, root=mx_model_root)
x = nd.zeros((1, 3, 512, 512))
net.hybridize()
net(x)
net.export(mx_model_root + mx_model)
mx.contrib.onnx.export_model(mx_model_root + mx_model + ‘-symbol.json’, mx_model_root + mx_model + ‘-0000.params’,
[x.shape], np.float32, onnx_model_root + mx_model + ‘.onnx’, verbose=False)

报的错误见下面
D:\ML_PY\python.exe E:/Python/ML/onnx_model_export.py
D:\ML_PY\lib\site-packages\mxnet\gluon\block.py:420: UserWarning: load_params is deprecated. Please use load_parameters.
warnings.warn(“load_params is deprecated. Please use load_parameters.”)
Traceback (most recent call last):
File “E:/Python/ML/onnx_model_export.py”, line 18, in
[x.shape], np.float32, onnx_model_root + mx_model + ‘.onnx’, verbose=False)
File “D:\ML_PY\lib\site-packages\mxnet\contrib\onnx\mx2onnx\export_model.py”, line 77, in export_model
verbose=verbose)
File “D:\ML_PY\lib\site-packages\mxnet\contrib\onnx\mx2onnx\export_onnx.py”, line 281, in create_onnx_graph_proto
idx=idx
File “D:\ML_PY\lib\site-packages\mxnet\contrib\onnx\mx2onnx\export_onnx.py”, line 92, in convert_layer
return convert_func(node, **kwargs)
File “D:\ML_PY\lib\site-packages\mxnet\contrib\onnx\mx2onnx_op_translations.py”, line 1731, in convert_slice_axis
raise ValueError(“Slice: ONNX doesnt’t support ‘None’ in ‘end’ attribute”)
ValueError: Slice: ONNX doesnt’t support ‘None’ in ‘end’ attribute

请问下怎么处理?

请问您解决了吗,我也遇到了相同的问题,是不是onnx还不够完善,还是gluon模型导出时需要设置什么?

请问你们解决了吗

那个自己算一下,然后在源码里面改一下就行

这个问题官方已经解决了https://github.com/apache/incubator-mxnet/issues/14875.

但是伴随的还会有其它的问题 还没找到解决方法.

---------------------------------------------------------------------------

AttributeError Traceback (most recent call last)
in ()
----> 1 converted_onnx_filename=mxnet_onnx.export_model(‘darknet-symbol.json’, ‘darknet-0000.params’, [(1,3,416,416)], np.float32, converted_onnx_filename)

~/anaconda3/envs/python3_tensorflow/lib/python3.6/site-packages/mxnet/contrib/onnx/mx2onnx/export_model.py in export_model(sym, params, input_shape, input_type, onnx_file_path, verbose)
81 onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
82 mapping.NP_TYPE_TO_TENSOR_TYPE[data_format],
—> 83 verbose=verbose)
84 elif isinstance(sym, symbol.Symbol) and isinstance(params, dict):
85 onnx_graph = converter.create_onnx_graph_proto(sym, params, input_shape,

~/anaconda3/envs/python3_tensorflow/lib/python3.6/site-packages/mxnet/contrib/onnx/mx2onnx/export_onnx.py in create_onnx_graph_proto(self, sym, params, in_shape, in_type, verbose)
236 proc_nodes=all_processed_nodes,
237 initializer=initializer,
–> 238 index_lookup=index_lookup)
239 graph_input_idx += 1
240

~/anaconda3/envs/python3_tensorflow/lib/python3.6/site-packages/mxnet/contrib/onnx/mx2onnx/export_onnx.py in convert_layer(node, **kwargs)
88 op = str(node[“op”])
89 if op not in MXNetGraph.registry_:
—> 90 raise AttributeError(“No conversion function registered for op type %s yet.” % op)
91 convert_func = MXNetGraph.registry_[op]
92 return convert_func(node, **kwargs)

AttributeError: No conversion function registered for op type null yet.