awslabs / keras-apache-mxnet

[DEPRECATED] Amazon Deep Learning's Keras with Apache MXNet support
https://github.com/awslabs/keras-apache-mxnet/wiki
Other
290 stars 65 forks source link

[Feature Request] Support exporting the model in ONNX model format #135

Open sandeep-krishnamurthy opened 6 years ago

sandeep-krishnamurthy commented 6 years ago

Currently, users train the model with Keras-MXNet, save the model as MXNet model using save_mxnet_model() API and use MXNet engine for inference.

However, if we can support a new API - save_onnx_model(), users can train with Keras-MXNet and export the model as ONNX model, and use different ONNX toolchain for inference.

High level implementation details:

  1. Update mxnet.contrib.onnx.export_model() to accept symbol and params or module object as the input. (current it expects the symbol and params file).
  2. Add new API in in keras/engine/saving.py - save_onnx_model() -> That calls internals of save_mxnet_model() to fetch MXNet native model details, calls mxnet.contrib.onnx.export_model() and saves the model as onnx.

Note: For this, we might require protobuf and other dynamic dependency for onnx. Need to dive deep on how we can handle this.

roywei commented 6 years ago

Possible solutions, need to be tested and verified: https://github.com/onnx/onnxmltools/pull/28 https://github.com/onnx/onnx/issues/877 https://github.com/leodestiny/onnx-keras