Running YOLOv8 on Mixtile Edge 2 Kit

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 Edge 2 Kit (hereinafter referred to as Edge 2) and perform inference.

Prerequisites

Before you start, make sure you have:

This guide has been tested with Debian 11.

Install dependencies

sudo apt update
sudo apt install -y libopencv-dev cmake build-essential

Download the demo and model

  1. Download the demo to a desired directory on Edge 2 (let’s say the home directory):

    cd ~
    git clone https://github.com/airockchip/rknn_model_zoo
    
  2. Download the yolov8n.rknn model:

    cd rknn_model_zoo/examples/yolov8/model
    wget https://downloads.mixtile.com/doc-files/yolov8/rk3568/yolov8n.rknn
    

    The yolov8n.rknn model above is converted from yolov8n.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 rk3568 -a aarch64 -d yolov8

Once the demo is compiled, the executable file rknn_yolov8_demo will be output to rknn_model_zoo/install/rk356x_linux_aarch64/rknn_yolov8_demo:

install
└── rk356x_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/rk356x_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/rk356x_linux_aarch64/rknn_yolov8_demo/out.png:

yolov8-inference-bus-output

Was this article helpful?

Related Articles