飞凌RK3568开发板试用体验】RKNN模型推理测试:https://bbs.elecfans.com/jishu_2321748_1_1.html【飞凌RK3568开发板试用体验】使用RKNN Toolkit2转换Pytorch模型:https://bbs.elecfans.com/jishu_2328460_1_1.html
今天我们主要使用厂商自己提供的模型来测试其RKNN推理能力。
首先,需要安装厂商提供的LuckFox
Pico SDK:https://github.com/LuckfoxTECH/luckfox-pico/。然后,安装瑞芯微的rknpu2:https://github.com/rockchip-linux/rknpu2。如果想转换自己的模型,还需要安装瑞芯微的RKNN Toolkit2:https://github.com/rockchip-linux/rknn-toolkit2。
在rknpu2的example目录下可以找到RV1106_RV1103目录,其中包括2个可以直接用于LuckFox Pico开发板的例程。
编译例程前需要设置如下环境变量:
export RK_RV1106_TOOLCHAIN=~/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf
然后执行examples/RV1106_RV1103/rknn_yolov5_demo目录下的build-linux_RV1106.sh脚本。该脚本将编译例程:
-- The C
compiler identification is GNU 8.3.0
-- The CXX
compiler identification is GNU 8.3.0
-- Check for
working C compiler:
/home/test/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc
-- Check for
working C compiler:
/home/test/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc
-- works
-- Detecting C
compiler ABI info
-- Detecting C
compiler ABI info - done
-- Detecting C
compile features
-- Detecting C
compile features - done
-- Check for
working CXX compiler:
/home/test/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++
-- Check for
working CXX compiler:
/home/test/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++
-- works
-- Detecting CXX
compiler ABI info
-- Detecting CXX
compiler ABI info - done
-- Detecting CXX
compile features
-- Detecting CXX
compile features - done
-- Configuring
done
-- Generating
done
-- Build files
have been written to:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/build/build_linux_arm
Scanning
dependencies of target rknn_yolov5_demo
[ 66%] Building
CXX object CMakeFiles/rknn_yolov5_demo.dir/src/postprocess.cc.o
[ 66%] Building
CXX object CMakeFiles/rknn_yolov5_demo.dir/src/main.cc.o
[100%] Linking
CXX executable rknn_yolov5_demo
[100%] Built
target rknn_yolov5_demo
[100%] Built
target rknn_yolov5_demo
Install the
project...
-- Install
configuration: ""
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/./rknn_yolov5_demo
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/lib/librknnmrt.so
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/.//model
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/.//model/bus.jpg
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/.//model/coco_80_labels_list.txt
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/.//model/RV1106
-- Installing:
/mnt/ok/rknpu2-master/examples/RV1106_RV1103/rknn_yolov5_demo/install/rknn_yolov5_demo_Linux/.//model/RV1106/yolov5s-640-640.rknn
连接板子的usb口到电脑,使用ADB命令将install目录下的整个demo目录复制到到 /userdata:
adb push install/rknn_yolov5_demo_Linux /userdata/
然后在板子上进入ADB shell运行程序。
adb shell
cd /userdata/rknn_yolov5_demo_Linux/
chmod 777 rknn_yolov5_demo
export LD_LIBRARY_PATH=/userdata/rknn_yolov5_demo_Linux/lib
./rknn_yolov5_demo model/RV1106/yolov5s-640-640.rknn model/bus.jpg
程序运行结果如下图:
我们用OpenCV绘制了识别结果,如下图。
识别的过程耗时100ms,速度还是相当快的。