apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.78k stars 6.79k forks source link

Import ONNX model from Pytorch to MXNet #17848

Open thomas-beznik opened 4 years ago

thomas-beznik commented 4 years ago

Description

Hello,

I am trying to convert an ONNX model coming from a PyTorch model to an MXNet model. The PyTorch model is an FPN that comes from this repository https://github.com/qubvel/segmentation_models.pytorch. I am running into the following error when using the method mxnet.contrib.onnx.onnx2mx.import_model

Error Message

Traceback (most recent call last): File "C:/Users/thoma/Documents/relu/AI_API/API/Detectors/Slice2DDetectorONNX.py", line 96, in sym, arg_params, aux_params = import_model(model_path) File "C:\Users\thoma\Documents\relu\AI_API\env\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_model.py", line 59, in import_model sym, arg_params, aux_params = graph.from_onnx(model_proto.graph) File "C:\Users\thoma\Documents\relu\AI_API\env\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_onnx.py", line 115, in from_onnx inputs = [self._nodes[i] for i in node.input] File "C:\Users\thoma\Documents\relu\AI_API\env\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_onnx.py", line 115, in inputs = [self._nodes[i] for i in node.input] KeyError: 'components.0.net.net.encoders.0.basic_module.SingleConv1.conv.weight'

I saw similar issues (such as https://github.com/apache/incubator-mxnet/issues/13395), which say that the problem comes from the fact that Dynamic Shape isn't implemented. But in my case, I am not using a dynamic shape; all my inputs are resized to a fixed shape before being fed to the model. Is there thus a way to easily change my architecture such that it uses this fixed shape and enables me to load my model in MXNet?

I can give more information if needed, any direction to solve this would be greatly appreciated!

To Reproduce

woolpeeker commented 4 years ago

I meet the same problem. Has it solved?