In this document, we will introduce how to convert the ONNX model into a model that can be used on the VIP9000 NPU. The first part introduces the working environment needed for model conversion. The second part introduces the steps of conversion.
1. Environment
Vivante Acuity toolkit installation completed
Vivante_IDE installation completed
Download acuity_examples_c901149.tgz for model conversation
The VIP9000 NPU kernel driver Acuity Toolkit and ViviantelIDE need to match the version:
VIP9000 NPU Kernel Driver | Acuity Toolkit | ViviantelIDE |
v6.4.13.8 | 6.18.1 | 5.7.2 |
v6.4.15.9 | 6.21.1 | 5.8.2 |
1.1. Prepare Acuity toolkit environment
Please refer to this document: Acuity toolkit environment
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
2. Transfer
2.1. Preparing
Create Model folder
mkdir yolov8s cd yolov8s
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.
cp ../yolov8s.onnx . cp ../input.jpg .
Create dataset.txt file, the content of dataset.txt is the input.jpg file name.
./input.jpg
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:
--inputs images --outputs 'onnx::Reshape_329 onnx::Reshape_344 onnx::Reshape_359' --input-size-list '3,640,640'
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 command in the console or terminal, and wait for it to complete.
./pegasus_import.sh yolov8s
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 .
./pegasus_quantize.sh yolov8s uint8
After the command execution is completed, you will see the following two files added under the folder.
Inference
Inference the ACUITY model with the quantization data type.
./pegasus_inference.sh yolov8s uint8
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.
./pegasus_export_ovx.sh yolov8s uint8
We can get the nb file and a c file for NN graph setup information.