注册 登录
电子工程世界-论坛 返回首页 EEWORLD首页 频道 EE大学堂 下载中心 Datasheet 专题
LitchiCheng的个人空间 https://home.eeworld.com.cn/space-uid-1003127.html [收藏] [复制] [分享] [RSS]
日志

RV1106手把手教你:yolov5图像识别模型从pt转换到onnx再到rknn

已有 339 次阅读2024-2-3 22:03 |个人分类:rv1106

安装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

 下载yolov5m-seg.pt很慢,直接使用地址下载

javascript:;

python3 export.py --rknpu --weight yolov5m-seg.pt

  安装下onnx

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:~

 将rknn的模型也复制到开发板

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
 

  视频讲解


 

本文来自论坛,点击查看完整帖子内容。

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

热门文章