Skip to content

tangyanf/createonnxmodel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

createonnxmodel

a tool to convert mmlab model to onnx

requirement

  • python >= 3.7

build createOnnx

git clone https://github.com.cnpmjs.org/tangyanf/createonnxmodel.git
cd createonnxmodel
python setup.py install

before use we need install mmcv-full

  • mmcv-full

    to install mmcv-full with custom ops, we need to download onnxruntime library, And add it into environment

    1. download onnxruntime-1.5.1
    wget https://github.com.cnpmjs.org/microsoft/onnxruntime/releases/download/v1.5.1/onnxruntime-linux-x64-1.5.1.tgz
    tar -zxvf onnxruntime-linux-x64-1.5.1.tgz
    1. add environment variable
    cd onnxruntime-linux-x64-1.5.1
    export ONNXRUNTIME_DIR=$(pwd)
    export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH
    1. build on linux
    git clone https://github.com.cnpmjs.org/open-mmlab/mmcv.git
    cd mmcv
    MMCV_WITH_OPS=1 MMCV_WITH_ORT=1 pip install -e .

usage

createOnnx --class-name detection \
           --config xxx.py \
           --checkpoint xxx.pth\
           --dynamic-shape \
           --onnx-name xxx.onnx \
           --simplify \
           --save-input \
           --save-output \
           --veirfy

Parameter Description

  • --class-name:         which class to convert(detection/classification/segmentation/editin)
  • --config:                  config file
  • --checkpoint:          checkpoint file
  • --dynamic-shape:   whether to export onnx with dynamic shape
  • --onnx-name:         output onnx model file's name
  • --simplify:               whether to simplify onnx model
  • --save-input:           whether to save model's input
  • --save-output:         whether to save onnxruntime's output
  • --verify :                  whether compare the outputs between Pytorch and ONNX

About

a tool to convert mmlab model to onnx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages