安装yolov5环境
git clone git@github.com:airockchip/yolov5.git
cd yolov5
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
使用yolov5官方模型进行预测测试
python3 segment/predict.py --weights yolov5m-seg.pt --data data/images/bus.jpg
https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5m-seg.pt
python3 export.py --rknpu --weight yolov5m-seg.pt
pip3 install onnx -i https://pypi.tuna.tsinghua.edu.cn/simple
下载rknn-toolkit2
git clone git@github.com:airockchip/rknn-toolkit2.git
安装rknn-toolkit2环境依赖
dar@dar:~/epan/rv1106/rknn-toolkit2/rknn-toolkit2/packages$ python3 --version
Python 3.8.10
pip3 install -r requirements_cp38-1.6.0.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
会出现版本的问题,换一个国内源
pip3 install -r requirements_cp38-1.6.0.txt -i https://mirrors.aliyun.com/pypi/simple
安装rknn_toolkit2包
pip3 install rknn_toolkit2-1.6.0+81f21f4d-cp38-cp38-linux_x86_64.whl -i http://pypi.douban.com/simple
测试库是否安装正常
python3
from rknn.api import RKNN
无报错
用test.py进行推理和转RKNN
进入dar@dar:~/epan/rv1106/rknn-toolkit2/rknn-toolkit2/examples/onnx/yolov5
运行python3 test.py
修改测试程序
git clone git@gitee.com:darboy/rknn_model_zoo.git
export GCC_COMPILER=/home/dar/epan/rv1106/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf
./build-linux.sh -t rv1106 -a armv7l -d yolov5
出现如下报错
[100%] Built target rknn_yolov5_demo
Install the project...
-- Install configuration: "Release"
-- Installing: /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/./rknn_yolov5_demo
-- Set runtime path of "/mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/./rknn_yolov5_demo" to "$ORIGIN/lib"
-- Installing: /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/./model/bus.jpg
-- Installing: /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/./model/coco_80_labels_list.txt
-- Installing: /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/lib/librknnmrt.so
-- Installing: /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/lib/librga.so
The RKNN model can not be found in "/mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l/rknn_yolov5_demo/model", please check!
不用管如上的模型没有,我们需要使用自己的rknn
将如下目录全部发送到rv1106开发板
cd /mnt/e/epan-ubuntu/rv1106/rknn_model_zoo/install/rv1106_linux_armv7l
scp -r rknn_yolov5_demo/ root@192.168.31.136:~
scp yolov5s_relu.rknn root@192.168.31.136:~
cp /root/yolov5s_relu.rknn model/
测试推理结果
./rknn_yolov5_demo model/yolov5s_relu.rknn model/bus.jpg
测试一张随便从网上下载的图片,侵删~
./rknn_yolov5_demo model/yolov5s_relu.rknn test-car.jpg