ehsanmok commented on issue #14875: MXNet to ONNX export bug
URL: 
https://github.com/apache/incubator-mxnet/issues/14875#issuecomment-492800991
 
 
   @vandanavk here is an MVE
   
   ```python
   from os import path as osp
   import numpy as np
   import mxnet as mx
   from mxnet.contrib import onnx as onnx_mxnet
   from mxnet import gluon
   from gluoncv import model_zoo, data, utils
   
   OUTPUT = "./output"
   DATA = "./data/cat.png"
   SIZE = 320
   MODEL = "yolo3_mobilenet1.0_coco"
   INPUT_SHAPE = (1, 3, SIZE, SIZE)
   
   net = model_zoo.get_model(MODEL, pretrained=True)
   net.hybridize()
   # pass an img to trigger init after hybridize
   x, _ = data.transforms.presets.yolo.load_test(DATA, short=SIZE)
   _, _ = net(x)
   
   net.export(osp.join(OUTPUT, MODEL))
   sym = osp.join(OUTPUT, MODEL + "-symbol.json")
   params = osp.join(OUTPUT, MODEL + "-0000.params")
   onnx_file = osp.join(OUTPUT, MODEL + ".onnx")
   
   converted_model_path = onnx_mxnet.export_model(sym, params, [INPUT_SHAPE], 
np.float32, onnx_file, verbose=True)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to