YOLOv8 is suitable for deployment on edge devices and real-time applications due to its speed and efficiency. This tutorial uses rknn_model_zoo to describe how to deploy YOLOv8 on Mixtile Blade 3 (hereinafter referred to as Blade 3) and perform inference.
Prerequisites
Before you start, make sure you have:
- Installed a Linux distribution on Blade 3 (see Installing an Operating System on Mixtile Blade 3) (this guide has tested with Ubuntu 22.04).
- Connected Blade 3 to the Internet.
This guide has been tested with Ubuntu 22.04 Desktop.
Install dependencies
sudo apt update
sudo apt install -y libopencv-dev cmake build-essential
Download the demo and model
-
Download the demo to a desired directory on Blade 3 (let’s say the home directory):
cd ~ git clone https://github.com/airockchip/rknn_model_zoo
-
Download the
yolov8n.rknn
model:cd rknn_model_zoo/examples/yolov8/model wget https://downloads.mixtile.com/doc-files/yolov8/rk3588/yolov8n.rknn
The
yolov8n.rknn
model above is converted fromyolov8n.onnx
for your convenience (see Convert to RKNN). You can also use other models as needed.
Compile the demo
# go to the rknn_model_zoo directory
cd ~/rknn_model_zoo
# grant permission to build-linux.sh
chmod 777 build-linux.sh
# compile the demo
./build-linux.sh -t rk3588 -a aarch64 -d yolov8
Once the demo is compiled, the executable file rknn_yolov8_demo
will be output to rknn_model_zoo/install/rk3588_linux_aarch64/rknn_yolov8_demo
:
install
└── rk3588_linux_aarch64
└── rknn_yolov8_demo
├── lib
│ ├── librga.so
│ └── librknnrt.so
├── model
│ ├── bus.jpg
│ ├── coco_80_labels_list.txt
│ └── yolov8n.rknn
├── rknn_yolov8_demo
└── rknn_yolov8_demo_zero_copy
Perform inference
Usage:
./rknn_yolov8_demo <model> <input-image>
Example:
The example below performs inference on the following model/bus.jpg
input image with the model/yolov8n.rknn
model:
# go to the directory of the executable file
cd ~/rknn_model_zoo/install/rk3588_linux_aarch64/rknn_yolov8_demo/
# set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./lib
# perform inference
./rknn_yolov8_demo model/yolov8n.rknn model/bus.jpg
Expected results
The output contains information similar to the one below, including the labels, coordinates, and their corresponding scores:
person @ (211 241 282 506) 0.864
bus @ (96 136 549 449) 0.864
person @ (109 235 225 535) 0.860
person @ (477 226 560 522) 0.848
person @ (79 327 116 513) 0.306
The output image will be saved as rknn_model_zoo/install/rk3588_linux_aarch64/rknn_yolov8_demo/out.png
: