You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/02/01 05:00:47 UTC

[GitHub] [incubator-mxnet] alicera opened a new issue #19808: onnx model

alicera opened a new issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808


   OS: ubuntu18.04
   NGC : nvcr.io/nvidia/mxnet:20.12-py3
   ONNX: 1.7.0   1.8.0
   
   I run the project to deal with onnx
   https://chai-bapat.medium.com/5min-gluon-model-to-onnx-e8ed0eea754e
   
   Error:
   [04:56:43] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
   resnest50 downloaded
   resnest50 hybridized
   resnest50 exported
   Traceback (most recent call last):
     File "pre.py", line 27, in <module>
       onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_model.py", line 81, in export_model
       onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 245, in create_onnx_graph_proto
       converted = MXNetGraph.convert_layer(
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 86, in convert_layer
       raise AttributeError("No conversion function registered for op type %s yet." % op)
   AttributeError: No conversion function registered for op type _contrib_AdaptiveAvgPooling2D yet.
   


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771332316






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


[GitHub] [incubator-mxnet] Jack6680 removed a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Jack6680 removed a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-848668068


   @Zha0q1 Good afternoon!
   I also managed to convert resnest50 to onnx with this script
   ```
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   model_name = 'resnest50'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   resnet50.export(model_name)
   print(model_name+' exported')
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   ```
   But I can't convert back from onnx to mxnet. Example
   ```
   import mxnet as mx
   import mxnet.contrib.onnx as onnx_mxnet
   sym, arg, aux = onnx_mxnet.import_model('./tp.onnx')
   
   ```
   ---------------------------------------------------------------------------
   `
   NotImplementedError: Operator ScatterND not implemented.`
   
   


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771332316


   Today, I try it again . It worked fine. Thanks for your help !!
   I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   pip install onnx==1.7.0
   
   ---------------------------------------------------------------------------
   But I try to use onnx2trt. 
   resnest14 and resnest26 fail.
   resnest50 worked fine.
   
   Command: onnx2trt resnest26.onnx -o 26.trt
   Error:
   [2021-02-02 03:37:30   ERROR] INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1
   While parsing node number 28 [ScatterND -> "resnest_layers1_splitattentionconv0_swapaxes0_perm_new"]:
   ERROR: /opt/mxnet/3rdparty/onnx-tensorrt/builtin_op_importers.cpp:3718 In function importFallbackPluginImporter:
   [8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"
   
   
   


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770646209


   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the project to deal with onnx.
   https://chai-bapat.medium.com/5min-gluon-model-to-onnx-e8ed0eea754e
   
   [07:45:24] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
   resnest50 downloaded
   resnest50 hybridized
   resnest50 exported
   Traceback (most recent call last):
     File "pre.py", line 27, in <module>
       onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_model.py", line 81, in export_model
       onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 257, in create_onnx_graph_proto
       converted = MXNetGraph.convert_layer(
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 88, in convert_layer
       return convert_func(node, **kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 1512, in convert_elementwise_add
       return create_basic_op_node('Add', node, kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 148, in create_basic_op_node
       name, input_nodes, _ = get_inputs(node, kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 140, in get_inputs
       input_node_name = outputs_lookup[ip[0]][ip[1]]
   IndexError: list index out of range
   
   


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770630011


   your last command was slightly off : )
   ```
   cp -r ./incubator-mxnet/python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   ```
   also you can use v1.x branch directly, no need to checkout that specific pr 


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


[GitHub] [incubator-mxnet] Jack6680 edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Jack6680 edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-848668068


   @Zha0q1 Good afternoon!
   I also managed to convert resnest50 to onnx with this script
   ```
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   model_name = 'resnest50'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   resnet50.export(model_name)
   print(model_name+' exported')
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   ```
   But I can't convert back from onnx to mxnet. Example
   ```
   import mxnet as mx
   import mxnet.contrib.onnx as onnx_mxnet
   sym, arg, aux = onnx_mxnet.import_model('./tp.onnx')
   
   ```
   ---------------------------------------------------------------------------
   `
   NotImplementedError: Operator ScatterND not implemented.`
   
   


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770632817


   Thanks,you are right.
   But I meet the new op error
   
   
   resn[07:22:10] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
   resnest50 downloaded
   resnest50 hybridized
   resnest50 exported
   Traceback (most recent call last):
     File "pre.py", line 27, in <module>
       onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_model.py", line 81, in export_model
       onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 254, in create_onnx_graph_proto
       converted = MXNetGraph.convert_layer(
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 86, in convert_layer
       raise AttributeError("No conversion function registered for op type %s yet." % op)
   AttributeError: No conversion function registered for op type SwapAxis yet.
   


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770604686


       'resnest14': resnest14,
       'resnest26': resnest26,
       'resnest50': resnest50,


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771393712


   Does it work fine with onnxruntime? 
   We are adding test coverage for the resnest models and the output values by onnxruntime seem to be different from mxnet naive outputs. We are actively working on debugging/improving this.
   Also may I ask what is your use case/application about?


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771332316


   Today, I try again it. It worked fine. Thanks for your help !!
   I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   pip install onnx==1.7.0
   
   ---------------------------------------------------------------------------
   But I try to use onnx2trt. 
   resnest14 and resnest26 fail.
   resnest50 worked fine.
   
   Command: onnx2trt resnest26.onnx -o 26.trt
   Error:
   [2021-02-02 03:37:30   ERROR] INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1
   While parsing node number 28 [ScatterND -> "resnest_layers1_splitattentionconv0_swapaxes0_perm_new"]:
   ERROR: /opt/mxnet/3rdparty/onnx-tensorrt/builtin_op_importers.cpp:3718 In function importFallbackPluginImporter:
   [8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"
   
   
   


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   
   
   > from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   
   model_name = 'resnest101'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   
   resnet50.export(model_name)
   print(model_name+' exported')
   
   #convert using onnx
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   #sym = mx.sym.load('./resnetfifty-symbol.json')
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   
   > 


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   
   > 
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   
   model_name = 'resnest101'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   
   resnet50.export(model_name)
   print(model_name+' exported')
   
   #convert using onnx
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   #sym = mx.sym.load('./resnetfifty-symbol.json')
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   


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


[GitHub] [incubator-mxnet] Zha0q1 edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770567596


   Hi @alicera which model are you trying to export?
   


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


[GitHub] [incubator-mxnet] Zha0q1 edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770630011


   @alicera
   your last command was slightly off : )
   ```
   cp -r ./incubator-mxnet/python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   ```
   also you can use v1.x branch directly, no need to checkout that specific pr 


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770646209


   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./incubator-mxnet/python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the project to deal with onnx.
   https://chai-bapat.medium.com/5min-gluon-model-to-onnx-e8ed0eea754e
   
   [07:45:24] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
   resnest50 downloaded
   resnest50 hybridized
   resnest50 exported
   Traceback (most recent call last):
     File "pre.py", line 27, in <module>
       onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_model.py", line 81, in export_model
       onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 257, in create_onnx_graph_proto
       converted = MXNetGraph.convert_layer(
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 88, in convert_layer
       return convert_func(node, **kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 1512, in convert_elementwise_add
       return create_basic_op_node('Add', node, kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 148, in create_basic_op_node
       name, input_nodes, _ = get_inputs(node, kwargs)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py", line 140, in get_inputs
       input_node_name = outputs_lookup[ip[0]][ip[1]]
   IndexError: list index out of range
   
   


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770635478


   @alicera 
   you can try v1.x without checkout out any earlier commit. We have just merged in the support for SwapAxis a few days ago : ) https://github.com/apache/incubator-mxnet/blob/v1.x/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L3432


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771084686


   @alicera I tried your script and it also worked fine. Were you able to export the model then?


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   
   > 
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   
   # download model
   model_name = 'resnest101'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   
   # convert to symbol
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   
   resnet50.export(model_name)
   print(model_name+' exported')
   
   #convert using onnx
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   #sym = mx.sym.load('./resnetfifty-symbol.json')
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   
   > 


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770647598


   We will look into this error on Mon


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   `from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   
   # download model
   model_name = 'resnest101'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   
   # convert to symbol
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   
   resnet50.export(model_name)
   print(model_name+' exported')
   
   #convert using onnx
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   #sym = mx.sym.load('./resnetfifty-symbol.json')
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')`


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-775385213


   @alicera For your information support for resnest is mature now - we have tested the exported onnx model and it produced the same output (onnxruntime) as the mxnet model


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented 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)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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770609976


   Another way would be to try to replace the files under python/mxnet/contrib/onnx/mx2onnx/ with the lattest versions in the v1.x branch


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771417934


   https://cv.gluon.ai/model_zoo/classification.html?from=groupmessage
   The project is very good.


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


[GitHub] [incubator-mxnet] Zha0q1 closed issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 closed issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808


   


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770609138


   @alicera I just checked the models and they did use `_contrib_AdaptiveAvgPooling2D`. The support for this operated has been recently added to the v1.x branch by this pr https://github.com/apache/incubator-mxnet/commit/e8e4fcde0f0d7fa11771c2deabb8cc27c0b99451. Would you try to build the v1.x branch from source? You can follow the instructions here https://mxnet.apache.org/versions/1.7.0/get_started/build_from_source. Please let me know if you can get it to work. 


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


[GitHub] [incubator-mxnet] Zha0q1 edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770647598


   We will look into this error on Mon and keep you updated


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771393712


   Does it work fine with onnxruntime? 
   We are adding test coverage for the resnest models and the output values by onnxruntime seem to be different from mxnet naive outputs. We are actively working on debugging/improving this.
   Also may I ask what is your use case/application about?


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


[GitHub] [incubator-mxnet] Zha0q1 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-775385532


   Closing this issue for now. Please feel free to reopen if you have any other questions


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-771332316


   Today, I try it again . It worked fine. Thanks for your help !!
   I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   pip install onnx==1.7.0
   
   ---------------------------------------------------------------------------
   But I try to use onnx2trt. 
   resnest14 and resnest26 fail.
   resnest50 worked fine.
   
   Command: onnx2trt resnest26.onnx -o 26.trt
   Error:
   [2021-02-02 03:37:30   ERROR] INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1
   While parsing node number 28 [ScatterND -> "resnest_layers1_splitattentionconv0_swapaxes0_perm_new"]:
   ERROR: /opt/mxnet/3rdparty/onnx-tensorrt/builtin_op_importers.cpp:3718 In function importFallbackPluginImporter:
   [8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"
   
   
   


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770632817


   Thanks, you are right.
   But I meet the new op error
   
   
   resn[07:22:10] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
   resnest50 downloaded
   resnest50 hybridized
   resnest50 exported
   Traceback (most recent call last):
     File "pre.py", line 27, in <module>
       onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_model.py", line 81, in export_model
       onnx_graph = converter.create_onnx_graph_proto(sym_obj, params_obj, input_shape,
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 254, in create_onnx_graph_proto
       converted = MXNetGraph.convert_layer(
     File "/opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py", line 86, in convert_layer
       raise AttributeError("No conversion function registered for op type %s yet." % op)
   AttributeError: No conversion function registered for op type SwapAxis yet.
   


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


[GitHub] [incubator-mxnet] alicera edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   
   
   > from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   model_name = 'resnest50'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   resnet50.export(model_name)
   print(model_name+' exported')
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770623298


   I do the thing
   git clone https://github.com/apache/incubator-mxnet
   git checkout v1.x
   git checkout e8e4fcd
   cp -r ./incubator-mxnet/python/mxnet/contrib/onnx/mx2onnx/  /opt/mxnet/python/mxnet/contrib/onnx/mx2onnx/
   
   then I run the project to deal with onnx.
   https://chai-bapat.medium.com/5min-gluon-model-to-onnx-e8ed0eea754e
   It is the same error.
   Does I miss some steps?
   
   Here is
   git branch
   * (HEAD detached at e8e4fcde0)
     master
     v1.x


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


[GitHub] [incubator-mxnet] Zha0q1 edited a comment on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Zha0q1 edited a comment on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770609138


   @alicera I just checked the models and they did use `_contrib_AdaptiveAvgPooling2D`. The support for this operated has been recently added to the v1.x branch by this pr https://github.com/apache/incubator-mxnet/commit/e8e4fcde0f0d7fa11771c2deabb8cc27c0b99451. Would you try to build the v1.x branch from source? You can follow the instructions here https://mxnet.apache.org/versions/1.7.0/get_started/build_from_source. Please let me know if you have any questions


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


[GitHub] [incubator-mxnet] alicera commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
alicera commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-770659754


   By the way, I based on NGC "nvcr.io/nvidia/mxnet:20.12-py3" to do 
   git clone --recursive https://github.com/apache/incubator-mxnet mxnet
   cd mxnet
   git checkout v1.x
   cp -r ./python/mxnet/contrib/onnx/mx2onnx/ /opt/mxnet/python/mxnet/contrib/onnx/
   
   then I run the script.
   here is the script
   `
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   
   # download model
   model_name = 'resnest101'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   
   # convert to symbol
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   
   resnet50.export(model_name)
   print(model_name+' exported')
   
   #convert using onnx
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   #sym = mx.sym.load('./resnetfifty-symbol.json')
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   `


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


[GitHub] [incubator-mxnet] Jack6680 commented on issue #19808: onnx model

Posted by GitBox <gi...@apache.org>.
Jack6680 commented on issue #19808:
URL: https://github.com/apache/incubator-mxnet/issues/19808#issuecomment-848668068


   Good afternoon!
   I also managed to convert resnest50 to onnx with this script
   ```
   from gluoncv import model_zoo
   import numpy as np
   import mxnet as mx
   model_name = 'resnest50'
   resnet50 = model_zoo.get_model(model_name, pretrained=True)
   print(model_name+' downloaded')
   resnet50.hybridize()
   print(model_name+' hybridized')
   input_shape=(1,3,224,224)
   data_array = np.random.uniform(0, 255, size=input_shape).astype("float32")
   mx_data = mx.nd.array(data_array)
   resnet50(mx_data)
   resnet50.export(model_name)
   print(model_name+' exported')
   from mxnet.contrib import onnx as onnx_mxnet
   onnx_file='./tp.onnx'
   params = './'+model_name+'-0000.params'
   sym='./'+model_name+'-symbol.json'
   onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   print('onnx export done')
   ```
   But I can't convert back from onnx to mxnet. Example
   ```
   import mxnet as mx
   import mxnet.contrib.onnx as onnx_mxnet
   sym, arg, aux = onnx_mxnet.import_model('./tp.onnx')
   
   ```
   ---------------------------------------------------------------------------
   `
   NotImplementedError: Operator ScatterND not implemented.`
   
   


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