Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of contents

...

Table of Contents
minLevel1
maxLevel4

Preparation

...

Please refer here for the environment construction procedure.

Conversion

...

Convert the model.

Please change the parameter "setting.conf" of the argument according to the model to be converted.

...

Note

Pytorch model needs to be converted to ONNX in advance

Setting.conf

...

Code Block
# Network Name
NET_NAME=mobilenet_v2

# SSD Model or Not (0:not SSD, 1:SSD)
IS_SSD=0

# Path to Directory for ONNX Models
MODEL_DIR=./sample/mobilenet_v2/models

# Path to Directory for DRA Images
DRA_IMAGE_DIR=../../dra_img

# Path to Directory for Output Data
OUTPUT_DIR=./out

# Quantization Mode
#  FIX8  : Fixed-point  8bit
#  FIX16 : Fixed-point 16bit
#  MIX   : FIX8/FIX16 mixed
PARSER_OPTION=MIX

# Input Data Format (0:NHWC, 1:NCHW)
IN_DATA_FORMAT=1

# Input Data Channel
IN_DATA_CHANNEL=3

# Input Data Width
IN_DATA_WIDTH=224

# Input Data Height
IN_DATA_HEIGHT=224

# Input Data Mean Vector
IN_MEAN=103.94,116.78,123.68

# Input Data Scale
# IN_SCALE=1/Scale
IN_SCALE=58.823529411

# RGB or BGR (0:RGB, 1:BGR)
IS_BGR=1

# Output Layers Name
OUT_LAYER=mobilenetv20_output_flatten0_reshape0

#cavalry version
#if not specified -> ""
CAVALRY_VER="2.1.7"

# Unique preprocess
# if use im2bin -> NONE
# if use unique preprocess -> script path
PREPRO=NONE
PREPRO_ARG=""

# Input file data format
IN_DATA_FILEFORMAT=0,0,0,0

# Transpose indices(NONE:without transpose , 0,3,1,2:transpose (EX))
IN_DATA_TRANSPOSE=NONE

...

Note

If there is a node that is not a constant, it cannot be converted normally.

In that case, convert the model using the following command, and perform quantization with the converted model.

-m : before conversion model

-o : after conversion model

Code Block
$ graph_surgery.py onnx -m mobilenetv210.onnx -o mobilenetv210_mod.onnx -t Default

Convert sample models

...

mobilenetv2

Move directory.

Code Block
$ cd /home/cvtool/conversion/onnx/mobilenetv2

...

Code Block
$ ./onnx_conversion.sh setting.conf

yolov5

Download sample model.

Code Block
$ cd /home/cvtool/conversion/onnx/yolov5
$ ./setup_yolov5.sh

...