Incubator-mxnet: [Feature Request] Support ONNX export of MultiBox operators

Created on 7 Jun 2019  路  11Comments  路  Source: apache/incubator-mxnet

Currently, the MXNet->ONNX model exporter does not support the MultiBox operators
MultiBoxDetection
MultiBoxPrior
MultiBoxTarget

Since there's no builtin ONNX operator (list) for this we would need to add the corresponding operators in ONNX first.

Feature request ONNX

Most helpful comment

I'm getting a "AttributeError: No conversion function registered for op type _contrib_MultiBoxPrior yet.". Same situations as https://stackoverflow.com/questions/56229207/export-mxnet-model-to-onnx-with-contrib-multiboxprior-error

  • I trained using AWS's object detection algorithm (Resnet50 + SSD).
  • Converted resultant training model (on S3 bucket) to a deploy model using "deploy.py" in mxnet's SSD examples.
  • Attempted to convert to from deploy model to ONNX model. Used

```import mxnet as mx
import numpy as np
from mxnet.contrib import onnx as onnx_mxnet
import logging
logging.basicConfig(level=logging.INFO)

Downloaded input symbol and params files

sym = './deploy_model_algo_1-symbol.json'
params = './deploy_model_algo_1-0000.params'

Standard Imagenet input - 3 channels, 512*512

input_shape = (1,3,512,512)

Path of the output file

onnx_file = './mxnet_exported.onnx'

converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)```

All 11 comments

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: ONNX, Feature

@mxnet-label-bot add[Feature request, ONNX]

tracked on the ONNX repo here - https://github.com/onnx/onnx/issues/2086

onnx 1.5 supports ssd now
https://github.com/onnx/onnx/issues/1552

I'm getting a "AttributeError: No conversion function registered for op type _contrib_MultiBoxPrior yet.". Same situations as https://stackoverflow.com/questions/56229207/export-mxnet-model-to-onnx-with-contrib-multiboxprior-error

  • I trained using AWS's object detection algorithm (Resnet50 + SSD).
  • Converted resultant training model (on S3 bucket) to a deploy model using "deploy.py" in mxnet's SSD examples.
  • Attempted to convert to from deploy model to ONNX model. Used

```import mxnet as mx
import numpy as np
from mxnet.contrib import onnx as onnx_mxnet
import logging
logging.basicConfig(level=logging.INFO)

Downloaded input symbol and params files

sym = './deploy_model_algo_1-symbol.json'
params = './deploy_model_algo_1-0000.params'

Standard Imagenet input - 3 channels, 512*512

input_shape = (1,3,512,512)

Path of the output file

onnx_file = './mxnet_exported.onnx'

converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)```

have the same exact issue as @ban1080 :/

That makes 3, is there any manual work around for this?

Same issue here:
AttributeError: No conversion function registered for op type _contrib_MultiBoxPrior yet.

Incidentally I followed the same process as @ban1080.

meet the same issue on aws sagemaker. it seams that the version of onnx in sagemaker's mxnet is 1.2.1. however, I tried to upgrade to 1.6.0. after that, the issue still occur.

pip install onnx==1.6.0

AttributeError Traceback (most recent call last)
in ()
1 # Invoke export model API. It returns path of the converted onnx model
----> 2 converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float16, onnx_file, True)
3
4 print(converted_model_path)
5 #converted_model_path = my_onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file, True)

~/anaconda3/envs/mxnet_p36/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/mxnet_p36/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)
251 initializer=initializer,
252 index_lookup=index_lookup,
--> 253 idx=idx
254 )
255

~/anaconda3/envs/mxnet_p36/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 _contrib_MultiBoxPrior yet.

@cloudrivers onnx 1.6 has a different version of opset definition than previous versions, see https://github.com/onnx/onnx/blob/master/docs/Versioning.md#released-versions

@szha any suggestion or sample codes for this issue? Customer trained on the SageMaker but can't transform to ONNX.
Here is the repeatable issue code

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luoruisichuan picture luoruisichuan  路  3Comments

realbns2008 picture realbns2008  路  3Comments

ranti-iitg picture ranti-iitg  路  3Comments

zy-huang picture zy-huang  路  3Comments

xzqjack picture xzqjack  路  3Comments