Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Before using the CANN DDK, you can use the offline model generator (OMG) to convert Caffe, TensorFlow, NNX, and MindSpore models into offline models (OMs), so that the mobile AI app can directly read the OM for inference. The OMG is located in the tools/tools_omg directory of the tools (obtained from Tool Download). It can run on 64-bit Linux.
Caffe 1.0 is currently supported.
See OMG Parameters for details about the parameters in the command. The conversion command is as follows:
- ./omg --model xxx.prototxt --weight yyy.caffemodel --framework 0 --output ./modelname
Conversion example:
- ./omg --model deploy.prototxt --weight squeezenet_v1.1.caffemodel --framework 0 --output ./squeezenet
If the log message "OMG generate offline model success" is printed, the model is successfully converted. A squeezenet.om file is generated in the current directory.
TensorFlow 2.x is currently supported.
See OMG Parameters for details about the parameters in the command. The conversion command is as follows:
- ./omg --model xxx.pb --framework 3 --output ./modelname --input_shape "xxx:n,h,w,c" --out_nodes "node_name1:0"
Conversion example:
- ./omg --model mobilenet_v2_1.0_224_frozen.pb --framework 3 --output ./mobilenet_v2 --input_shape "input:1,224,224,3" --out_nodes "MobilenetV2/Predictions/Reshape_1:0"
If the log message "OMG generate offline model success" is printed, the model is successfully converted. A mobilenet_v2.om file is generated in the current directory.
Currently, ONNX opset versions 7 to 18 are supported (the latest supported version is V1.13.1).
See OMG Parameters for details about the parameters in the command. The conversion command is as follows:
- ./omg --model xxx.onnx --framework 5 --output ./modelname
Conversion example:
- ./omg --model resnet18.onnx --framework 5 --output ./resnet18
If the following logs are printed, the model is successfully converted. A resnet18.om file is generated in the current directory.

Most models use the 16-bit float type for computation on the NPU. Quantizing models can reduce the model size and thereby accelerate model inference.
Model conversion with quantization depends on the size reduction tool. The compress_conf parameter is passed to the OMG to generate a quantized model. For details, please refer to Model Size Reduction.
See OMG Parameters for details about the parameters in the command. The conversion command is as follows:
- ./omg --model xxx.prototxt --weight xxx.caffemodel --framework 0 --output ./modelname --compress_conf=param
Conversion example:
- ./omg --model deploy.prototxt --weight squeezenet_v1.1.caffemodel --framework 0 --output ./squeezenet --compress_conf=param
If the log message "OMG generate offline model success" is printed, the model is successfully quantized. A quantized model squeezenet.om is generated in the current directory.
If a model needs to be loaded at a time, and different batches or image sizes may appear in different inference processes, you can use the variable shape before the inference.
To do so, before performing model conversion, specify all of the shape types that may appear during model inference through dynamic_dims and input_shape, to generate a standard IR model that carries multiple input shapes.
For details about parameters in the command, see OMG Parameters.
Conversion example:
- ./omg --model=./1batch.onnx --input_shape="inputName:-1,3,128,128" --dynamic_dims="1;2;5" --framework=5 --output=./FlexibleShapeModelName
The AIPP module is introduced for input pre-processing including image cropping and resizing, color space conversion (CSC), mean subtraction and factor multiplication, and much more. Operators are added to the converted model to replace these operations, improving the efficiency.
This feature is available since CANN DDK V310.
See OMG Parameters for details about the parameters in the command. The conversion command is as follows:
- ./omg --model xxx.prototxt --weight xxx.caffemodel --framework 0 --insert_op_conf aipp_conf_static.cfg --output ./modelname
Conversion example:
- ./omg --model deploy.prototxt --weight squeezenet_v1.1.caffemodel --framework 0 --insert_op_conf aipp_conf_static.cfg --output ./squeezenet
If the log message "OMG generate offline model success" is printed, the model is successfully converted. An AIPP model squeezenet.om is generated in the current directory.
aipp_conf_static.cfg in the tools/tools_omg/sample folder is the AIPP configuration file. For details, please refer to AIPP Configuration File.
MindSpore supports a limited number of operators. You are advised to use TensorFlow Model Conversion or ONNX Model Conversion instead.