Convert Tool

Usage

Convert Tool is located at SGS_IPU_SDK/Scripts/ConvertTool/ConvertTool.py. The tool supports conversion of framework models including tensorflow_graphdef, tensorflow_savemodel, keras, tflite, and caffe into SGS floating-point network models. Before use, run the following script under SGS_IPU_SDK directory and output the Library path (can be ignored, if this has already been done):

cd ~/SGS_IPU_SDK 
source cfg_env.sh

The following provides information on the ConvertTool supported platforms:

python3 ConvertTool.py -h  
usage: ConvertTool.py [-h] 
    {tensorflow_graphdef,tensorflow_savemodel,keras,tflite,caffe,onnx} ... 
Convert Tool 
    positional arguments: {tensorflow_graphdef,tensorflow_savemodel,keras,tflite,caffe,onnx} 
        platform info

    tensorflow_graphdef 
        tensorflow graphdef commands

    tensorflow_savemodel 
        tensorflow save_model commands

    keras 
        keras commands

    tflite 
        tflite commands

    caffe 
        caffe commands

    onnx
        onnx commands

optional arguments: 
    -h, --help show this help message and exit

To view the parameters necessary for conversion of the respective platforms, execute python3 ConvertTool.py {platform} –h. Set forth below are detailed descriptions of each platform and the associated arguments:

Tensorflow_graphdef

python3 ConvertTool.py tensorflow_graphdef -h 
usage: ConvertTool.py tensorflow_graphdef [-h] 
    --graph_def_file GRAPH_DEF_FILE 
    --input_arrays INPUT_ARRAYS (optional)
    --output_arrays OUTPUT_ARRAYS (optional)
    --input_config INPUT_CONFIG 
    --output_file OUTPUT_FILE 
    --input_shapes INPUT_SHAPES (optional)
    --debug  (optional)

optional arguments: 
    -h, --help 
        show this help message and exit.

    --graph_def_file 
        GRAPH_DEF_FILE Full filepath of file containing frozen GraphDef.

    --input_arrays 
        INPUT_ARRAYS Names of the input arrays, comma-separated.

    --output_arrays 
        OUTPUT_ARRAYS Names of the output arrays, comma-separated.

    --input_config 
        INPUT_CONFIG Input config path.

    --output_file 
        OUTPUT_FILE Full filepath of out Model path.

    --input_shapes 
        INPUT_SHAPES Shapes corresponding to --input_arrays, colon-separated. For many models each shape takes the form batch size, input array height, input array width, input array depth. Default: None

Example:

python3 ConvertTool.py tensorflow_graphdef \ 
--graph_def_file ~/SGS_Models/tensorflow/resnet_v2_50/resnet_v2_50.pb \ 
--output_file ./resnet_v2_float.sim \ 
--input_shapes 1,299,299,3 \ 
--input_config ~/SGS_Models/tensorflow/resnet_v2_50/input_config.ini

Related parameters:

--graph_def_file: Path to pb format file of TensorFlow frozen graphdef input model.

--output_file: Output model file in flatbuffer format, with sim extension.

--input_shapes: Shape of network input Tensor, in NHWC format. If there are multiple dimensions, use a comma (,) to separate them. The number of shapes corresponds to the number of inputs. Use a colon (:) to separate multiple shapes.

--input_config: Path to input_config.ini file, which contains the input Tensor configuration information.

Optional Parameters:

--input_arrays: Name of network input Tensor, specified by string type. If there are multiple inputs, separate them with a comma (,), for example, --input_arrays='Input1','Input2'.

--output_arrays: Name of network output Tensor, specified by string type. If there are multiple outputs, separate them with a comma (,).

Tensorflow_savemodel

python3 ConvertTool.py tensorflow_savemodel -h 
usage: ConvertTool.py tensorflow_savemodel [-h] 
    --saved_model_dir SAVED_MODEL_DIR 
    --input_config INPUT_CONFIG   
    --output_file OUTPUT_FILE 
    --output_arrays OUTPUT_ARRAYS (optional)    
    --input_arrays INPUT_ARRAYS (optional)
    --input_shapes INPUT_SHAPES (optional)
    --tag_set TAG_SET (optional)
    --signature_key SIGNATURE_KEY (optional)

optional arguments: 
    -h, --help 
        show this help message and exit.

    --saved_model_dir 
        SAVED_MODEL_DIR SavedModel directory to convert.

    --input_config 
        INPUT_CONFIG Input config path.

    --output_file 
        OUTPUT_FILE Full filepath of out Model path. --debug Run gdb in Debug mode.

    --input_arrays 
        INPUT_ARRAYS Names of the input arrays, comma-separated. 
        Default: None.

    --output_arrays 
        OUTPUT_ARRAYS Names of the output arrays, comma-separated. 
        Default: None.

    --input_shapes 
        INPUT_SHAPES Shapes corresponding to --input_arrays, colon- separated. For many models each shape takes the form batch size, input array height, input array width, input array depth
        Default: None.

    --tag_set 
        TAG_SET Set of tags identifying the MetaGraphDef within the SavedModel to analyze. All tags in the tag set must be present.  
        Default: None.

    --signature_key 
        SIGNATURE_KEY Key identifying SignatureDef containing inputs and outputs.  
        Default: DEFAULT_SERVING_SIGNATURE_DEF_KEY

Example:

python3 ConvertTool.py tensorflow_savemodel \ 
--saved_model_dir ~/test/tensorflow_model/save_model \ 
--input_config ~/test/tensorflow_model/input_config.ini \ 
--output_file ~/test/tensorflow_model/save_model_float.sim \ 
--tag_set test_saved_model \ 
--signature_key test_signature

Related parameters:

--saved_model_dir: Path to file generated by TensorFlow saved_model.builder input model.

--output_file: Output model file in flatbuffer format, with sim extension.

--input_config: Path to input_config.ini file, which contains the input Tensor configuration information.

Optional parameters:

--input_arrays: Name of network input Tensor, specified by string type. If there are multiple inputs, separate them with a comma (,), for example, --input_arrays='Input1','Input2'. If this parameter is not specified, the name will be given by saved_model_dir.

--output_arrays: Name of network output Tensor, specified by string type. If there are multiple outputs, separate them with a comma (,). If this parameter is not specified, the name will be given by saved_model_dir.

--input_shapes: Shape of network input Tensor, in NHWC format. If there are multiple dimensions, use a comma (,) to separate them. The number of shapes corresponds to the number of inputs. Use a colon (:) to separate multiple shapes. If this parameter is not specified, the name will be given by saved_model_dir.

--tag_set: Must match with the tag specified when saving model. If this parameter is not specified, ‘serve’ will be taken by default.

--signature_key: Must match with the signature specified when saving model. If this parameter is not specified, ‘DEFAULT_SERVING_SIGNATURE_DEF_KEY’ will be taken by default.

Keras

python3 ConvertTool.py keras -h 
usage: ConvertTool.py keras [-h] 
    --model_file MODEL_FILE 
    --input_config INPUT_CONFIG  
    --output_file OUTPUT_FILE
    --input_arrays INPUT_ARRAYS (optional)    
    --output_arrays OUTPUT_ARRAYS (optional)
    --input_shapes INPUT_SHAPES (optional)
    --custom_objects CUSTOM_OBJECTS (optional)

optional arguments: 
    -h, --help show this help message and exit 
    --model_file MODEL_FILE Full filepath of HDF5 file containing the tf.keras model.

    --input_config INPUT_CONFIG Input config path.

    --output_file OUTPUT_FILE Full filepath of out Model path.

    --input_arrays INPUT_ARRAYS Names of the input arrays, comma-separated.
    Default: None.

    --input_shapes INPUT_SHAPES Shapes corresponding to --input_arrays, colon- separated. For many models each shape takes the form batch size, input array height, input array width, input array depth.  
    Default: None.

    --output_arrays OUTPUT_ARRAYS Names of the output arrays, comma-separated.
    Default: None.

    --custom_objects CUSTOM_OBJECTS Dict mapping names (strings) to custom classes or functions to be considered during model deserialization.
    Default: None.

Example:

python3 ConvertTool.py keras \ 
--model_file ./TEST_h5/resnet50/resnet50.h5 \ 
--input_config ./TEST_h5/resnet50/input_config.ini \ 
--output_file ./TEST_h5/resnet50/resnet50_float.sim

Related parameters:

--model_file: Path to Keras h5 format input model file.

--output_file: Output model file in flatbuffer format, with sim extension.

--input_config: Path to input_config.ini file, which contains the input Tensor configuration information.

Optional parameters:

--input_arrays: Name of network input Tensor, specified by string type. If there are multiple inputs, separate them with a comma (,), for example, --input_arrays='Input1','Input2'.

--output_arrays: Name of network output Tensor, specified by string type. If there are multiple outputs, separate them with a comma (,).

--input_shapes: Shape of network input Tensor, in NHWC format. If there are multiple dimensions, separate them with a comma (,). The number of shapes corresponds to the number of inputs. Use a colon (:) to separate multiple shapes.

--custom_objects: Dict mapping names (strings) to custom classes or functions to be considered during model deserialization (default None).

TFLite

python3 ConvertTool.py tflite -h 
usage: ConvertTool.py tflite [-h] 
    --model_file MODEL_FILE 
    --input_config INPUT_CONFIG 
    --output_file OUTPUT_FILE

optional arguments: 
    -h, --help show this help message and exit

    --model_file MODEL_FILE Full filepath of tflite file containing the tflite model.

    --input_config INPUT_CONFIG Input config path.

    --output_file OUTPUT_FILE Full filepath of out Model path.

Example:

python3 ConvertTool.py tflite \ 
--model_file ~/test/tensorflow_model/Debug_save_model_float.tflite \ 
--input_config ~/test/tensorflow_model/input_config.ini \ 
--output_file ~/test/tensorflow_model/save_model_float.sim

Related parameters:

--model_file: Path to TFLite format input model file. (The model must be a non-quantized model.)

--output_file: Output model file in flatbuffer format, with sim extension.

--input_config: Path to input_config.ini file, which contains the input Tensor configuration information.

Caffe

python3 ConvertTool.py caffe -h 
usage: ConvertTool.py caffe [-h] 
    --model_file MODEL_FILE 
    --weight_file WEIGHT_FILE 
    --input_config INPUT_CONFIG 
    --output_file OUTPUT_FILE 
    --input_arrays INPUT_ARRAYS (optional)
    --output_arrays OUTPUT_ARRAYS (optional)

optional arguments: 
    -h, --help show this help message and exit

    --model_file MODEL_FILE Full filepath of tflite file containing the caffe model.

    --weight_file WEIGHT_FILE Full filepath of tflite file containing the caffe weight.

    --input_config INPUT_CONFIG Input config path.

    --output_file OUTPUT_FILE Full filepath of out Model path.

    --input_arrays INPUT_ARRAYS Names of the input arrays, comma-separated.
    Default: None.

    --output_arrays OUTPUT_ARRAYS Names of the output arrays, comma-separated. 
    Default: None.

Example:

python3 ConvertTool.py caffe \ 
--model_file ~/SGS_Models/caffe/caffe_resnet50_conv/caffe_resnet50_conv.prototxt \ 
--weight_file ~/SGS_Models/caffe/caffe_resnet50_conv/caffe_resnet50_conv.caffemodel \ 
--input_config ~/SGS_Models/caffe/caffe_resnet50_conv/input_config.ini \ 
--output_file ./resnet50.sim

Related parameters:

--model_file: Path to Caffe model file.

--weight_file: Path to Caffe weight file.

--input_config: Path to input_config.ini file, which contains the input configuration information.

--output_file: Output path of the converted model.

Optional parameters:

--input_arrays: Name of the Caffe input pack model, using the input name.

--output_arrays: Name of the Caffe output pack model, using the top name of the last layer. If there are multiple output nodes, separate them with a comma (,).

Onnx

python3 Path_to_SGS_IPU_SDK/Scripts/ConvertTool.py onnx -h 
usage: ConvertTool.py onnx [-h] 
--model_file MODEL_FILE 
--input_arrays  INPUT_ARRAYS (optional)
--input_shapes INPUT_SHAPES  
--output_arrays OUTPUT_ARRAYS (optional)
--input_config  INPUT_CONFIG 
--output_file OUTPUT_FILE

optional arguments:  -h, --help show this help message and exit  
--model_file MODEL_FILE  Full filepath of tflite file containing the onnx  model.

--input_arrays INPUT_ARRAYS  Names of the input arrays, comma-separated. (default  None).

--input_shapes INPUT_SHAPES  Shapes corresponding to --input_arrays, colon-separated. For many models each shape takes the form N  C H W (default None)

--output_arrays OUTPUT_ARRAYS  Names of the output arrays, comma-separated. (default  None)

--input_config INPUT_CONFIG  Input config path.

--output_file OUTPUT_FILE  Full filepath of out Model path.

Example:

python3 ~/SGS_IPU_SDK/Scripts/ConvertTool/ConvertTool.py onnx 
--model_file  ~/SGS_Models/onnx/ onnx_mobilenet_v2/ onnx_mobilenet_v2.onnx 
--input_config ~/SGS_Models/onnx/ onnx_mobilenet_v2/input_config.ini 
--output_file ./onnx_mobilenet_v2_float.sim

Related parameters:

--model_file: Path to Onnx model file.

--input_shapes: Onnx model input shape. If there are multiple shapes, separate them with a colon (:).

--input_config: Path to input_config.ini file, which contains the input configuration information.

--output_dir: Output path of the converted model.

--input_pack_model: Way of arrangement of the model input. Normally NHWC for Onnx models converted by TensorFlow, and NCHW for Onnx models converted by Caffe or PyTorch.

Optional parameters:

--input_arrays: Name of the Onnx model input node, using the input name. If there are multiple inputs, separate them with a comma (,).

--output_arrays: Name of the Onnx model output node, using the top name of the last layer. If there are multiple output nodes, separate them with a comma (,).

Notes on Onnx Model Conversion

Please remove post-processing operators in the model, if any. Currently, only backbone network conversion is supported.

Notes

After the conversion by Convert Tool is done, two files will be generated. For example, if --output_dir is designated to ./resnet50.sim, Debug_resnet50.sim and resnet50.sim will be generated after the conversion. Among them, resnet50.sim is the real converted file, while Debug_resnet50.sim is the converted intermediate file. This intermediate file is not optimized and has the same network structure as the original framework model, so it can be used for debugging after conversion, but it cannot be run in the IPU SDK.

Configuration Options

The tool parameter --input_config needs to specify the path of the input Tensor configuration file input_config.ini. This file provides the following functions:

  • Configuring the normalized information for network model picture pre-processing.

  • Configuring the quantized processing information of the input and output of the network model.

  • Configuring the quantized information of the convolution in the network model.

Configuring input_config.ini file is mainly for fast adaptation of the network model to SigmaStar chip. During network model training, the network needs to use different picture normalization methods depending on the requirements of different frameworks and training data sets. In actual use, in order to make the prediction of the network model more accurate, it is necessary to restore the normalization method used for pre-processing of pictures during model training. After the average value of the RGB channels and the std_value are set up, they will be written into the network model during conversion, so that when the model is actually used on hardware, the picture need only be resized to the size of the input network model, while the normalization is automatically completed within the network. In addition, the input format of the picture actually used on hardware may be very different from the RGB format used during training. Correctly configuring these options can ensure that the converted model contains the configuration information required for direct deployment on SigmaStar hardware.

[INPUT_CONFIG]
;Names of the input arrays, comma-separated.image input must be the first.
inputs='data';
;Memory formats of input arrays, comma-separated.
;One of RGB, BGR, RGBA, BGRA, YUV_NV12, RAWDATA_S16_NHWC
;Each entry in the list should match an entry in inputs arrays.
training_input_formats=BGR;
input_formats=BGR;
;Indicate the input data need qauntize or not.
;Each entry in the list should match an entry in inputs arrays.
quantizations=TRUE;
;mean_values parameter for image models,
;Each entry in the list match RGB channel of(RGB,BGR,RGBA,BGRA,YUV_NV12)
mean_red=0.0;
mean_green=0.0;
mean_blue=0.0;
;std_value parameter for image models, 
std_value=1.0;

[OUTPUT_CONFIG]
;Names of the output arrays, comma-separated.
outputs='prob';
;Indicate the output data need deqauntize or not.  
;Each entry in the list should match an entry in outputs arrays.
dequantizations=TRUE;

[CONV_CONFIG]
;input_format=ALL_INT16;
tensor_arrays='conv1-1,conv2-1';

As shown, this file contains the following three configuration options:

[INPUT_CONFIG]
[OUTPUT_CONFIG]
[CONV_CONFIG]

Note

String type value, such as Tensor name, needs to be indicated in parenthesis (' '), for example, outputs='detectionBoxes,detectionClasses,detectionScores,numDetections';

INPUT_CONFIG

  • inputs: Name of the network input Tensor. The length of name is less than 1024. If there are multiple input Tensors, separate them with a comma (,). The order of sequence of the input Tensor should be in accord with that of the inputs configured.

  • training_input_formats: Picture format used in network training, where the number and order of sequence correspond to those of the inputs configured. Use a comma (,) to separate multiple formats. Valid formats include RGB, BGR, and RAWDATA_S16_NHWC (if training_input_formats is set to RAWDATA_S16_NHWC, then input_formats should be set to RAWDATA_S16_NHWC as well). The training_input_formats can be different from the input_formats. For example, on the SigmaStar development board, the input_formats can be YUV_NV12 while the training_input_formats is RGB.

  • input_formats: Input format of picture of the network model run on the SigmaStar chip. Their number and order of sequence correspond to those of the inputs configured. If there are multiple input formats, separate them with a comma (,). Valid formats include:

    • RGB
    • BGR
    • RGBA
    • BGRA
    • YUV_NV12
    • RAWDATA_S16_NHWC

    Note

    • The following settings about training_input_formats and input_formats are illegal.
        training_input_formats=RGB;
        input_formats=BGR;
    
        or
    
        training_input_formats=BGR;
        input_formats=RGB;
    
    • Configure grayscale images as follows
        training_input_formats=RGB;
        input_formats=GRAY;
    
    Refer to Special Model Conversion for more details.
    
    • When configuring RAWDATA_S16_NHWC, there is no need to config mean_red, mean_green, mean_blue and std_value.
  • quantizations: It is used to identify, by TRUE or FALSE, whether the data of all input Tensors need to be quantized, where the number is equal to the number of the inputs configured. If there are multiple input Tensors, separate them with a comma (,).

  • mean_red / mean_green / mean_blue: During network training phase, pictures are generally pre-processed. For pictures with RGB channels, the following formula is used to pre-process the pictures:

    \frac {RGB-[mean\_red, mean\_green, mean\_blue]} {std\_value}

    mean_red/mean_green/mean_blue is the mean value on the corresponding channel. If the network under process does not require normalization, the value can be set to 0. Each mean value is equal to the number of inputs. If there are multiple input Tensors, separate them with a comma (,).

  • std_value: According to the formula above, if no normalization is to be done, this value can be set to 1. And if each channel has a corresponding std_value, separate them with a colon (:), in RGB order. If there are multiple input Tensors, separate them with a comma (,).

  • yuv420_h_pitch_alignment: Used to identify the extent of alignment in the H direction when YUV data is used as a network input; default is 16.

  • yuv420_v_pitch_alignment: Used to identify the extent of alignment in the V direction when YUV data is used as a network input; default is 2.

  • xrgb_h_pitch_alignment: Used to identify the extent of alignment in the H direction when XRGB data is used as a network input; default is 16.

Note

The above three configurations can only accept integer multiples of the default value.
For example, yuv420_h_pitch_alignment=32;


OUTPUT_CONFIG

outputs: Name of the network output Tensor (network model can be opened by Netron). The length of name is less than 1024. If there are multiple output Tensors, separate them with a comma (,). When converting post-processing network model, the name of outputs of backbone network is different from the name of outputs of the entire network; otherwise, the settings are the same. The order of sequence of the output Tensor should be in accord with that of the outputs configured.

dequantizations: It is used to identify, by TRUE or FALSE, whether the data of all output Tensors need to be dequantized, where the number is equal to the outputs configured. If there are multiple output Tensors, separate them with a comma (,). This option only takes effect when running on the board.

CONV_CONFIG

input_format: Specifies all the quantization methods for convolution in the network. The default value is L5. Options include ALL_UINT8, ALL_INT16, CONV2D_INT16, and DEPTHWISE_INT16.

  • ALL_UINT8: All convolutions are quantized according to UINT8.
  • ALL_INT16: All convolutions are quantized according to INT16.
  • CONV2D_INT16: All normal convolutions are quantized according to INT16.
  • DEPTHWISE_INT16: All depthwise convolutions are quantized according to INT16.

In UINT8 mode, the convolution operation occupies a small bandwidth and runs fast, whereas in INT16 mode, the accuracy of the convolution can be greatly improved, but the speed of the operation will be slower.

tensor_arrays: Specifies the quantization method for convolution of some layers in the network. Since the entire network convolution would use UINT8 as the default quantization method, when some convolutional layers require higher accuracy, you can directly fill in the Tensor name of the first input of those convolutional layers requiring higher accuracy. For multiple layers, names are separated by a comma (,).

Note

The name of the first input Tensor of the convolution can be viewed through the Netron tool.

OPTIMIZE_CONFIG

skip_concatenation: Skips concatenation layer in network. This optimization parameter will go effective when only the last dimension is merged. With this parameter set, fixed models will convert the concatenation layer to skip_concatenation layer, thereby considerably reducing the operation time.

Summary

training_input_formats input_formats Device Firmware Data Alignment
RGB/BGR RGB/BGR Don't care
RGB/BGR RGBA/BGRA W = ALIGN_UP(W * 4, xrgb_h_pitch_alignment) / 4
RGB/BGR YUV_NV12/GRAY H = ALIGN_UP(H, yuv420_v_pitch_alignment)
W = ALIGN_UP(W, yuv420_h_pitch_alignment)
RAWDATA_S16_NHWC RAWDATA_S16_NHWC the last tensor dimension = ALIGN_UP(the last tensor dimension, 8)
  • If dequantizations is set to TRUE, Fix2Float will be added and data type of model output will be converted from INT16 to float32 at runtime. There is no need to align the data.

  • If dequantizations is set to FALSE, data type of model output will be INT16. Data alignment is needed.

    data alignment: the last tensor dimension = ALIGN_UP(the last tensor dimension, 8)

One-click Model Conversion

The ConvertModels tool is located at SGS_IPU_SDK/Scripts/ConvertTool/ConvertModels.py. This tool converts the original model into SigmaStar offline model directly with a single click. To perform this one-click conversion, you need only prepare the input_config.ini file by configuring the parameters needed for each stage of the model conversion.

Run the following script under the SGS_IPU_SDK directory and output the Library path (can be ignored, if this has already been done):

cd ~/SGS_IPU_SDK
source cfg_env.sh

Configure the mandatory parameters in the input_config.ini file, then run the following command to activate one-click conversion into SigmaStar offline model.

python3 ~/SGS_IPU_SDK/Scripts/ConvertTool/ConvertModels.py \
--input_config ./input_config.ini

Below is an exemplary input_config.ini file configuration:

[PLATFORM]
;Name of model framework. one of onnx,caffe,tensorflow_graphdef, keras,tflite
platform=caffe;
[INPUT_MODEL_NAME]
;Name of models,where is the models location.comma-separated.
model_files=xxxx.caffemodel,xxxx.prototxt;
;Name of special case in the models, eg. lstm
[SPECIAL_MODEL_CASE]
special_case=
[OUTPUT_MODEL_NAME]
;Name of output models.
output_file=xxxx_float.sim;
[SPECIAL_PARAMS]
; (only tensorflow save_model)Set of tags identifying the MetaGraphDef within the SavedModel to analyze. All tags in the tag set must be present. (default None)
tag_set=
; (only tensorflow save_model) Key identifying SignatureDef containing inputs and outputs.(default DEFAULT_SERVING_SIGNATURE_DEF_KEY)
signature_key=
; (only keras)Dict mapping names (strings) to custom classes or functions to be considered during model deserialization. (default None)
custom_objects=
;preprocess py name,if null,will automatic generation
preprocesspy_name=

; (only caffe)Set input Pack model, specify name pack model like caffe(NCHW),comma-separated. ;All inputTersors will be NCHW if set "caffe" (default is NHWC)
input_pack_model_arrays=
;(only caffe)Set output Pack model, specify name pack model like caffe(NCHW),comma-separated.; All outputTersors will be NCHW if set "caffe" (default is NHWC)
output_pack_model_arrays=
;(only onnx) input tensor pack model,NCHW(caffe pytorch) or NHWC(tensorflow).
; default NCHW
input_pack_model=
[CALIBRATOR]
;images file or dir if mult_inputs,file which lists of images  
images_path=./ILSVRC2012_test_00000002.bmp;
;category one of Classification,Detection,Unknown
category_name=Unknown;
;number of process
num_process=
;quantlization level, one of L1,L2,L3,L4,L5
quant_level=
[INPUT_CONFIG]
;Names of the input arrays, comma-separated.image input must be the first.
inputs=input;
;Memory formats of input arrays, comma-separated.
;One of RGB, BGR, RGBA, BGRA, ARGB, ABGR YUV_NV12, RAWDATA_S16_NHWC
;Each entry in the list should match an entry in inputs arrays.
training_input_formats=BGR;
input_formats=RGB;
;Indicate the input data need qauntize or not.  
;Each entry in the list should match an entry in inputs arrays.
quantizations=TRUE;
;mean_values parameter for image models,
;Each entry in the list match RGB channel of(RGB,BGR,RGBA,BGRA,YUV_NV12)
mean_red=123.68;
mean_green=116.78;
mean_blue=103.94;
;std_value parameter for image models,
std_value=1.0;
;input data shape;
input_shapes=1,3,224,224;
[OUTPUT_CONFIG]
;Names of the output arrays, comma-separated.
outputs=prob;
;Indicate the output data need deqauntize or not.  
;Each entry in the list should match an entry in outputs arrays.
dequantizations=TRUE;
[CONV_CONFIG]
tensor_arrays=conv1-1,conv2-1;

Mandatory Parameter

platform: Name of model framework, such as caffe, onnx, tflite, keras, tensorflow_graphdef, and tensorflow_savemodel.

model_files: Name of original model file.

output_file: Name of floating-point model output file. (Model will be generated at the current working directory; if it is an absolute path, then the model is output to specified directory.)

images_path: Name of image file or directory to be quantized. If there are multiple input models, upload the image path file.

category_name: Name of the category to which the model belongs, e.g. Classification, Detection, and Unknown.

inputs: Name of the network input Tensor. If there are multiple input Tensors, separate them with a comma (,).

training_input_formats: Picture format used in network training. See INPUT_CONFIG for details.

input_formats: Picture format used in model conversion. See INPUT_CONFIG for details.

quantizations: Input node quantization indicated by TRUE or FALSE. See INPUT_CONFIG for details.

mean_red: Image R-channel normalized value. See INPUT_CONFIG for details.

mean_green: Image G-channel normalized value. See INPUT_CONFIG for details.

mean_blue: Image B-channel normalized value. See INPUT_CONFIG for details.

std_value: Image normalized value. See INPUT_CONFIG for details.

input_shapes: Image dimension of the model input, for example, 1,3,224,224 or 1,224,224,3.

outputs: Model output node. See OUTPUT_CONFIG for details.

dequantizations: Output node dequantization indication by TRUE or FALSE. See OUTPUT_CONFIG for details.

Optional Parameter

special_case: Special node operator in model, such as lstm.

tag_set: Must match with the tag specified when saving model. If this parameter is not specified, ‘serve’ will be taken by default (for tensorflow_savemodel only).

signature_key: Must match with the signature specified when saving model (for tensorflow_savemodel only).

custom_objects: When deserializing model, it is recommended to map the name string to custom class or function using a lookup table (for keras only).

preprocesspy_name: Picture preprocessing file; if this parameter is null, the file will be generated automatically.

num_process: Number of processes running simultaneously. (Optional parameter; if not specified, 10 processes will be run by default.)

quant_level: Quantization level selection: [Ll, L2, L3, L4, L5]. The default quantization level is L5.

input_pack_model_arrays: The input Tensor format of data array is NHWC, default is None. For ‘Caffe’, the input Tensor data will be set in NCHW format.

output_pack_model_arrays: The output Tensor format of data array is NHWC, default is None. For ‘Caffe’, the output Tensor data will be set in NCHW format.

input_pack_model: For Onnx model input Tensors, the default data format is NCHW. If this Onnx model is converted by TensorFlow, the value should be set to ‘NHWC’.