mxnet-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-mxnet] Zha0q1 edited a comment on issue #19808: onnx model
Date Mon, 01 Feb 2021 08:02:40 GMT

Zha0q1 edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770654979


   Actually I just tried exporting on the latest v1.x branch and was able to do it with all
3 models.
   This is the script I used:
   ```
   from gluoncv import model_zoo, data, utils
   from matplotlib import pyplot as plt
   import numpy as np
   import mxnet as mx
   import gluonnlp as nlp
   from mxnet.contrib import onnx as onnx_mxnet
   import onnx
   
   model_name = 'resnest50'
   
   net = model_zoo.get_model(model_name, pretrained=True)
   net.hybridize()
   
   im_fname = utils.download('https://github.com/dmlc/web-data/blob/master/' +
                             'gluoncv/detection/street_small.jpg?raw=true',
                             path='street_small.jpg')
   x, img = data.transforms.presets.ssd.load_test(im_fname, short=512)
   print('Shape of pre-processed image:', x.shape)
   
   pred = net(x)
   
   net.export(model_name)
   
   
   input_shapes = [(1,3,512,512)]
   sym_file = model_name + '-symbol.json'
   params_file = model_name + '-0000.params'
   onnx_file = model_name + '.onnx'
   converted_model_path = onnx_mxnet.export_model(sym_file, params_file, input_shapes,
                                                  np.float32, onnx_file, verbose=True)
   ```
   @alicera would you give it a try? Also can you share your script? thanks


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


Mime
View raw message