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/12/30 18:07:32 UTC

[GitHub] [incubator-mxnet] cyrusbehr opened a new issue #17195: Unable to convert Insightface resnet 100 model to onnx

cyrusbehr opened a new issue #17195: Unable to convert Insightface resnet 100 model to onnx
URL: https://github.com/apache/incubator-mxnet/issues/17195
 
 
   I originally posted this question to the onnxruntime github page, but was hold to repost it here. The original post can be found [here](https://github.com/microsoft/onnxruntime/issues/2743#issue-542643478): 
   
   
   I am trying to convert the Insightface resnet 100 model (` LResNet100E-IR,ArcFace@ms1m-refine-v2`) which can be found [here](https://github.com/deepinsight/insightface/wiki/Model-Zoo) to work with onnxruntime. 
   
   I use the following conversion python script to convert the model. The model converts successfully.
   
   ```
   import mxnet as mx
   import numpy as np
   from mxnet.contrib import onnx as onnx_mxnet
   import logging
   logging.basicConfig(level=logging.INFO)
   
   sym = 'model-symbol.json'
   params = 'model-0000.params'
   
   input_shape = (1,3,112,112)
   
   # Path of the output file
   onnx_file = './insightface_resnet100.onnx'
   converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file)
   
   from onnx import checker
   import onnx
   
   model_proto = onnx.load_model(converted_model_path)
   
   # Check if converted ONNX protobuf is valid
   checker.check_graph(model_proto.graph)
   ```
   
   Next, I try to load the model in C++ using the following code. Note, I am following the example found [here](https://github.com/microsoft/onnxruntime/blob/master/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp) : 
   ```
   int main(int argc, char* argv[]) {
       Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "test");
       Ort::SessionOptions session_options;
       session_options.SetIntraOpNumThreads(1);
   
       session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
       const char* model_path = "../models/insightface_resnet100.onnx";
   
       Ort::Session session(env, model_path, session_options);
   
       return 0;
   }
   ```
   
   When I run this code, I get the following error:
   ```
   terminate called after throwing an instance of 'Ort::Exception'
     what():  Type Error: Type parameter (T) bound to different types (tensor(float) and tensor(double) in node (_minusscalar0).
   Aborted
   
   ```
   
   I am using `libonnxruntime.so.1.1.0`

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

[GitHub] [incubator-mxnet] deimsdeutsch commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx

Posted by GitBox <gi...@apache.org>.
deimsdeutsch commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx
URL: https://github.com/apache/incubator-mxnet/issues/17195#issuecomment-570144769
 
 
   Faced similar issue 2 months and decided against it. Glad it is being taken up.

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

[GitHub] [incubator-mxnet] cyrusbehr commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx

Posted by GitBox <gi...@apache.org>.
cyrusbehr commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx
URL: https://github.com/apache/incubator-mxnet/issues/17195#issuecomment-573801868
 
 
   Thank you for your answer @litaotju 
   After looking into this again, I realized that when I convert the model using `python mxnet2onnx.py`, then the error is generated when loading the model. However, if I use `python3 mxnet2onnx.py` to convert the model, the model can be loaded without error. 
   
   **Solution**: Use python 3 to convert the 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


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] litaotju commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx

Posted by GitBox <gi...@apache.org>.
litaotju commented on issue #17195: Unable to convert Insightface resnet 100 model to onnx
URL: https://github.com/apache/incubator-mxnet/issues/17195#issuecomment-573282608
 
 
   Tried your scripts and cpp file. The cpp application can load the exported onnx without any error.
   
   I am using 
   - onnx: `pip3 install --user onnx==1.2.1`
   - onnxruntime: `wget https://github.com/microsoft/onnxruntime/releases/download/v1.1.0/onnxruntime-linux-x64-1.1.0.tgz`
   - mxnet: master branch, commit id: 6f95702613dd95aa4a1b467b938d79c4d13bee96
   - Docker container: built from `ci/docker/Dockerfile.build.ubuntu_gpu_tensorrt`.
   
   You only mentioned the `onnxruntime` version, but which version `mxnet` and `onnx` are you using? Maybe just upgrade to latest  mxnet and try again?
   
   
   

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

[GitHub] [incubator-mxnet] cyrusbehr closed issue #17195: Unable to convert Insightface resnet 100 model to onnx

Posted by GitBox <gi...@apache.org>.
cyrusbehr closed issue #17195: Unable to convert Insightface resnet 100 model to onnx
URL: https://github.com/apache/incubator-mxnet/issues/17195
 
 
   

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

[GitHub] [incubator-mxnet] cyrusbehr edited a comment on issue #17195: Unable to convert Insightface resnet 100 model to onnx

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


   Thank you for your answer @litaotju 
   After looking into this again, I realized that I was indeed using an older version, and upgrading solved the issue. 


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