[Rock Pi] (3) RK3588S development board deploys yolov5 model (officially provided model)

reference

rockchip rknn-tookit2
rockchip rknpu2

Introduction to development environment

Host PC: Installed with ubuntu22.04 (others can also be referenced)
Docker: ubuntu20.04
development board: rock 5a with rk3588s chip
Host environment configuration
[Rock Pi 1] Rock pi enables VNC remote desktop for VNC+KDE desktop
[ Rock Pi 2] rknn host-side configuration docker development environment deployment

YOLO v5 model deployment (C++ version)

Source code download (host side)

#根据上篇文章创建的docker虚拟机编号执行下面指令进入docker虚拟机
dengml@dengml-SER:~$ sudo docker exec -it -u dengml -w /home/dengml 612c918d5027 /bin/bash
[sudo] dengml 的密码:
dengml@612c918d5027:~$ cd /data/ubuntu/rockpi/rknn-toolkit2
#执行以下命令使能之前创建的python虚拟环境(虽然本节似乎没用到宿主机的python)
dengml@612c918d5027:/data/ubuntu/rockpi/rknn-toolkit2$ source venv/bin/activate
#获取rknpu2源代码
(venv) dengml@612c918d5027:/data/ubuntu/rockpi$ git clone https://kgithub.com/rockchip-linux/rknpu2.git

This code contains demos of multiple models such as yolo v5. Here we first deploy the officially provided rknn model.

Install cross-compilation tools (host side)

The Ubuntu software library already contains the cross-aarch64-linux cross-compilation tool chain, so in line with the principle of simplicity, you can directly use apt to install it as follows:

$ sudo apt update
$ sudo apt-get install gcc-aarch64-linux-gnu
$ sudo apt-get install g++-aarch64-linux-gnu
#安装 cmake 编译工具
$ sudo apt install cmake

Source code compilation (host side)

$ cd rknpu2/examples/rknn_yolov5_demo
$ ./build-linux_RK3588.sh
#代码通过scp到开发板端,也可以通过winscp、samba、等其他方式
$ scp -r install/rknn_yolov5_demo_Linux [email protected]:~/work

Verification (development board side)

After scp the compiled binary and model files to the board, log in to the development board through ssh.
develop board

#打开cp过来的目录
rock@rock-5a:~$ cd work/rknn_yolov5_demo_Linux/
#添加运行依赖的动态库
rock@rock-5a:~/work/rknn_yolov5_demo_Linux$ export LD_LIBRARY_PATH=./lib
#执行识别命令
rock@rock-5a:~/work/rknn_yolov5_demo_Linux$ ./rknn_yolov5_demo model/RK3588/yolov5s-640-640.rknn model/bus.jpg

The result after executing the command is as shown in the figure
Insert image description here

The running log is as shown in the figure. First, click the SFTP file manager interface (marked "1") on the moba interface. Clicking "2" can generally directly open the directory where the terminal on the right is located. If it cannot be opened automatically, just Enter the directory where our terminal on the right is located at "3", as shown in the picture above. We can see that a new file out.jpg is generated, which is the result of the model generation. At this point, the deployment of the C++ version of rknn model is completed. Double-click to open, the results are as follows
result_by_c

YOLO v5 model deployment (Python version)

Development board installs conda virtual environment

Load rknn-toolkit2 repository

Run the example

Guess you like

Origin blog.csdn.net/weixin_43328157/article/details/132678098