Incubator-mxnet: mxnet fail to import onnx model

Created on 14 Aug 2020  路  3Comments  路  Source: apache/incubator-mxnet

Description

mxnet fail to import onnx model exported by pytorch. The model is from https://github.com/biubug6/Pytorch_Retinaface

Error Message

(Paste the complete error message. Please also include stack trace by setting environment variable DMLC_LOG_STACK_TRACE_DEPTH=10 before running your script.)

  File "/disk/zhitingz/video-pipeline/sprocket/platform/lambda_program/onnxruntime/detection/detect.py", line 139, in mx_init
    sym, arg_params, aux_params = onnx_mxnet.import_model(mpath)
  File "/disk/zhitingz/mxnet-cpu/lib/python3.6/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 "/disk/zhitingz/mxnet-cpu/lib/python3.6/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 115, in from_onnx
    inputs = [self._nodes[i] for i in node.input]
  File "/disk/zhitingz/mxnet-cpu/lib/python3.6/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 115, in <listcomp>
    inputs = [self._nodes[i] for i in node.input]
KeyError: '1'

To Reproduce

(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)
Get the exported onnx model. I fork the above link: https://github.com/photoszzt/Pytorch_Retinaface with some helper script to reproduce this issue easier.

  1. download the pretrain pytorch model and export the model
cd weights
./download_all_pretrain.sh
cd -
./export_models.sh
  1. try to load the model with the follwoing code.
from mxnet.contrib import onnx as onnx_mxnet
sym, arg_params, aux_params = onnx_mxnet.import_model('./mnet.0.25.onnx')

What have you tried to solve it?

  1. I try to print the node.input. It's ['input0', '1'].
Bug ONNX

All 3 comments

Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on contributing to MXNet and our development guides wiki.

I update the issue with my forked repo that contains some helpful scripts to reproduce this issue.

cc @josephevans and @ChaiBapchya

Was this page helpful?
0 / 5 - 0 ratings