NN Model Conversion
In this document, we will introduce how to convert the ONNX model into a model that can be used on the C3V NPU. The first part introduces the working environment needed for model conversion. The second part introduces the steps of conversion.
1. Environment
NN toolkit installation completed
NN IDE installation completed
Download acuity_examples_c901149.tgz for model conversation
The download link is below:
The NPU kernel driver, NN Toolkit, and NN IDE need to match the version:
NPU Kernel Driver | NN Toolkit | NN IDE |
v6.4.13.8 | 6.18.1 | 5.7.2 |
v6.4.15.9 | 6.21.1 | 5.8.2 |
v6.4.18.5 | 6.30.7 | 5.10.1 |
1.1. Prepare NN Toolkit Environment
Please refer to this document: Vivante ACUITY Toolkit
Export environment variable.
export ACUITY_PATH=/home/users/data/share/c3v/acuity-toolkit-whl-6.18.1/bin
1.2. Install the IDE
Please refer to this document: VivanteIDE Install
1.3. Uncompress Examples
tar xvf acuity_examples_c901149.tgz
Suppose the fold is named c3v. The file path is as follows
Create Script Soft Connection.
cd Model
source env.sh
1.4. Demo Video
2. Transfer
2.1. Preparing
Create Model folder
Copy the ONNX file as the input. copy the input.jpg which resolution is 640x640. Please make sure the folder name is as same as the ONNX file name.
Create a dataset.txt file, the content of dataset.txt is the input.jpg file name.
Create inputs_outputs.txt file and get the information from yolov8s.onnx via netron tool/webpage.
write --input-size-list and --outputs informations to inputs_outputs.txt:
After completing the above steps, there will be the following files under yolov8s:
2.2. Implementing
Import
This command will import and translate an NN model to ACUITY formats. Execute the command in the console or terminal, and wait for it to complete.
After the command execution is completed, you will see the following four files added under the folder.
Quantize
Please modify the scale value(1/255) of yolov8s_inputmeta.yml.
Please select one quantized type for your need, such as uint8 / int16 / bf16 / pcq .
After the command execution is completed, you will see the following two files added under the folder.
Inference
Inference the NN model with the quantization data type.
Export
Export the quantized application for device deployment. If you want to get the network binary, please modify the pegasus_export_ovx.sh for the nb file generating, and add both 3 lines marked in the red box.
We can get the NB file and a c file for NN graph setup information.
2.3. Demo Video
This video is the demo for yolov8s-detection int16 quantize.