You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/09/18 01:37:58 UTC

[GitHub] [incubator-mxnet] SyGoing edited a comment on issue #16176: When convert mxnet model (simple pose) to onnx , the deconvolution’s convert function miss?

SyGoing edited a comment on issue #16176: When convert mxnet model (simple pose) to onnx , the deconvolution’s convert function miss?
URL: https://github.com/apache/incubator-mxnet/issues/16176#issuecomment-532480935
 
 
   my code  is here:
   
   import mxnet
   import mxnet  as mx
   from mxnet.contrib import onnx as onnx_mxnet
   from onnx import checker
   import onnx
   
   from gluoncv import model_zoo
   from gluoncv.utils import export_block
   from mxnet.gluon.model_zoo import vision
   
   def gen_symbol_param_file_form_gluoncv_test():
       pose_net = model_zoo.get_model('simple_pose_resnet18_v1b', pretrained=True)
       x = mxnet.ndarray.random.normal(shape=(1, 3,192,256))
       pose_net.hybridize()
       predicted_heatmap=pose_net(x)
       pose_net.export("test")
   
   
   def generate_onnx_file(symbol_path,param_path,onnx_path,input_shape=(1,3,192,256)):
       logging.basicConfig(level=logging.INFO)
   
       net_symbol = mxnet.symbol.load(symbol_path)
       net_params_raw = mxnet.nd.load(param_path)
       net_params = dict()
       for k, v in net_params_raw.items():
           tp, name = k.split(':', 1)
           net_params.update({name: v})
   
       onnx_mxnet.export_model(net_symbol, net_params, [input_shape], numpy.float32, onnx_path, verbose=True)
   
       # Load onnx model
       model_proto = onnx.load_model(onnx_path)
   
       # Check if converted ONNX protobuf is valid
       checker.check_graph(model_proto.graph)
   
   
   if __name__ == '__main__':
       gen_symbol_param_file_form_gluoncv_test()
       generate_onnx_file('test-symbol.json','test-0000.params','simple_base.onnx')

----------------------------------------------------------------
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


With regards,
Apache Git Services