YOLO26
This document describes how to run YOLO26 on NPU.
Refer to Model Zoo Download for the example.
YOLO26 Example Directory Structure:
$ tree ./
./
├── CMakeLists.txt
├── convert_model
│ ├── config_yml.py
│ ├── convert_model_env.sh
│ ├── python
│ │ ├── onnx_extract.py
│ │ └── yolo26s_640.txt
│ └── yolo26s_6.txt
├── figures
│ ├── banner-yolo26.png
│ ├── bus.jpg
│ ├── out_yolo26_6_pcq.png
│ └── performance-comparison.png
├── main.cpp
├── model
│ └── dog.jpg
├── model_config.h
├── README.md
├── yolov26_6_post.cpp
└── yolov26_6_pre.cpp
Model Conversion
Configure Virtual Environment
python -m venv .venv && source .venv/bin/activate
pip install ultralytics
Export ONNX Model
ultralytics will automatically download the model and any missing dependencies. Please be patient.
cd convert_model/python/
yolo export model=yolo26s.pt format=onnx simplify=True dynamic=False opset=16
Prune Model
python onnx_extract.py
cd ..
Create Symlink for Conversion Script
./convert_model_env.sh
Model Import/Quantization/Conversion
You need to enter the container development environment first. Refer to the Create Container section in Model Zoo Download.
Different platforms use corresponding Docker images:
- A733: ubuntu-npu:v2.0.10.1
- T527: ubuntu-npu:v1.8.11
docker exec -it model-zoo /bin/bash
After entering the container, navigate to the corresponding directory and run the script.
# Navigate to the corresponding directory in the container
cd /workspace/examples/yolo26/convert_model/
./pegasus_import.sh yolo26s_6 # Model name without suffix
./pegasus_quantize.sh yolo26s_6 pcq 12
- A733
- T527
./pegasus_export_ovx_nbg.sh yolo26s_6 pcq a733
./pegasus_export_ovx_nbg.sh yolo26s_6 pcq t527
The exported model files are stored in the ../model directory.
Compile Example
Now you can compile the example. First exit the container, then execute the following command to compile the example.
First, you need to configure third-party libraries and cross-compilation toolchain.
You can skip this step if you have already configured third-party libraries and cross-compilation toolchain in other examples.
cd ../../../3rdparty/opencv/
unzip opencv-4.9.0-aarch64-linux-sunxi-glibc.zip
cd ../../0-toolchains/
You need to manually download via this link first, then place it in 0-toolchains/ before executing the following command:
tar -xvf gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz
- A733
- T527
cd ../examples/yolo26/
../build_linux.sh -t a733 -s debian11
cd ../examples/yolo26/
../build_linux.sh -t t527 -s debian11
Model Deployment
After compilation, the example will be installed in the install directory. You can use scp to transfer it to the board.
Configure NPU Driver
You can skip this step if you have already configured NPU driver in other examples.
Transfer the driver library to the board's lib directory via scp.
- A733 corresponds to the common/lib_linux_aarch64/A733 directory
- T527 corresponds to the common/lib_linux_aarch64/T527 directory
Then execute the following command to export to environment variables.
echo 'export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
Run Example
After configuring the driver, you can run the example.
For T527 platform, you need to first enable NPU by referring to the A5E's "Enable NPU on Board" documentation, then use the following command to grant the current user permission to use /dev/vipcore.
sudo chmod 777 /dev/vipcore
- A733
- T527
cd yolo26_demo_linux_a733/
chmod +x ./yolo26_demo_a733
./yolo26_demo_a733 -nb model/yolo26s_6_pcq_a733.nb -i model/dog.jpg
The running result is as follows:
$ ./yolo26_demo_a733 -nb model/yolo26s_6_pcq_a733.nb -i model/dog.jpg
model_file=model/yolo26s_6_pcq_a733.nb, input=model/dog.jpg, loop_count=1, malloc_mbyte=10
VIPLite driver software version 2.0.3.2-AW-2024-08-30
input 0 dim 3 640 640 1, data_format=2, quant_format=0, name=input/output[0], none-quant
output 0 dim 6400 4 1 0, data_format=0, name=uid_20000_sub_uid_1_out_0, none-quant
output 1 dim 1600 4 1 0, data_format=0, name=uid_20001_sub_uid_1_out_0, none-quant
output 2 dim 400 4 1 0, data_format=0, name=uid_20002_sub_uid_1_out_0, none-quant
output 3 dim 6400 80 1 0, data_format=0, name=uid_20003_sub_uid_1_out_0, none-quant
output 4 dim 1600 80 1 0, data_format=0, name=uid_20004_sub_uid_1_out_0, none-quant
output 5 dim 400 80 1 0, data_format=0, name=uid_20005_sub_uid_1_out_0, none-quant
nbg name=model/yolo26s_6_pcq_a733.nb, size: 9362920.
create network 0: 18319 us.
prepare network: 8871 us.
buffer ptr: 0x5cb2600, buffer size: 1228800
network: 0, loop count: 1
run time for this network 0: 34765 us.
output 0, ptr 0x5dde740, size 25600.
output 1, ptr 0x5df77c0, size 6400.
output 2, ptr 0x5dfdc40, size 1600.
output 3, ptr 0x5dff5c0, size 512000.
output 4, ptr 0x5ff3680, size 128000.
output 5, ptr 0x6070700, size 32000.
postprocess time : 6 ms
detection num: 3
7: 68%, [ 466, 74, 690, 171], truck
1: 89%, [ 130, 136, 566, 420], bicycle
16: 90%, [ 133, 221, 310, 540], dog
destroy npu finished.
~NpuUint.
This performance data only calculates the time consumption of model inference. Unless otherwise specified, it does not include the time consumption of pre-processing and post-processing.
| SoC | NPU | Model | Input Resolution | Network Creation Time | Network Preparation Time | Single Frame Inference Time | Post-processing Time | Total Time | Frame Rate |
|---|---|---|---|---|---|---|---|---|---|
| Allwinner A733 | Vivante VIP9000 | yolo26s | 640×640 | 18.3 ms | 8.9 ms | 34.8 ms | 6 ms | 68.0 ms | 28.7 FPS |
cd yolo26_demo_linux_t527/
chmod +x ./yolo26_demo_t527
./yolo26_demo_t527 -nb model/yolo26s_6_pcq_t527.nb -i model/dog.jpg
The running result is as follows:
$ ./yolo26_demo_t527 -nb model/yolo26s_6_pcq_t527.nb -i model/dog.jpg
model_file=model/yolo26s_6_pcq_t527.nb, input=model/dog.jpg, loop_count=1, malloc_mbyte=10
VIPLite driver software version 1.13.0.0-AW-2023-10-19
input 0 dim 3 640 640 1, data_format=2, quant_format=0, name=input[0], none-quant
output 0 dim 6400 4 1 0, data_format=0, name=uid_20000_sub_uid_1_out_0, none-quant
output 1 dim 1600 4 1 0, data_format=0, name=uid_20001_sub_uid_1_out_0, none-quant
output 2 dim 400 4 1 0, data_format=0, name=uid_20002_sub_uid_1_out_0, none-quant
output 3 dim 6400 80 1 0, data_format=0, name=uid_20003_sub_uid_1_out_0, none-quant
output 4 dim 1600 80 1 0, data_format=0, name=uid_20004_sub_uid_1_out_0, none-quant
output 5 dim 400 80 1 0, data_format=0, name=uid_20005_sub_uid_1_out_0, none-quant
nbg name=model/yolo26s_6_pcq_t527.nb, size: 9920576.
create network 0: 20397 us.
prepare network: 11311 us.
buffer ptr: 0x6fe6600, buffer size: 1228800
network: 0, loop count: 1
run time for this network 0: 87270 us.
output 0, ptr 0x7112700, size 25600.
output 1, ptr 0x712b780, size 6400.
output 2, ptr 0x7131c40, size 1600.
output 3, ptr 0x71335c0, size 512000.
output 4, ptr 0x7327640, size 128000.
output 5, ptr 0x73a46c0, size 32000.
postprocess time : 20 ms
detection num: 2
1: 94%, [ 128, 135, 566, 418], bicycle
16: 92%, [ 133, 219, 311, 541], dog
destroy npu finished.
~NpuUint.
This performance data only calculates the time consumption of model inference. Unless otherwise specified, it does not include the time consumption of pre-processing and post-processing.
| SoC | NPU | Model | Input Resolution | Network Creation Time | Network Preparation Time | Single Frame Inference Time | Post-processing Time | Total Time | Frame Rate |
|---|---|---|---|---|---|---|---|---|---|
| Allwinner T527 | Vivante VIP9000 | yolo26s | 640×640 | 20.4 ms | 11.3 ms | 87.3 ms | 20.0 ms | 139.0 ms | 11.5 FPS |