瑞芯微Rockchip开发者社区
登录
直播中
罗星
9年用户
1643经验值
擅长:模拟技术
私信
关注
[问答]
求大佬分享RK3399运行瑞芯微官方yolov5 C++代码
开启该帖子的消息推送
深度学习
RK3399
求大佬分享RK3399运行瑞芯微官方yolov5 C++代码
回帖
(1)
谢海莲
2022-3-7 09:39:35
运行结果
img width = 1280, img height = 720
Loading mode...
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI: API: 1.4.0 (bbe0dfc build: 2020-09-14 14:06:05)
D RKNNAPI: DRV: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
D RKNNAPI: ==============================================
sdk version: 1.4.0 (bbe0dfc build: 2020-09-14 14:06:05) driver version: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
model input num: 1, output num: 3
index=0 name=images_165 n_dims=4 dims=[1 3 640 640] n_elems=1228800 size=1228800 fmt=0 type=3 qnt_type=2 fl=0 zp=0 scale=0.003922
index=0 name=Conv_Conv_159/out0_0 n_dims=4 dims=[1 255 80 80] n_elems=1632000 size=1632000 fmt=0 type=3 qnt_type=2 fl=0 zp=187 scale=0.127843
index=1 name=Conv_Conv_160/out0_1 n_dims=4 dims=[1 255 40 40] n_elems=408000 size=408000 fmt=0 type=3 qnt_type=2 fl=0 zp=182 scale=0.113217
index=2 name=Conv_Conv_161/out0_2 n_dims=4 dims=[1 255 20 20] n_elems=102000 size=102000 fmt=0 type=3 qnt_type=2 fl=0 zp=172 scale=0.103272
model is NCHW input fmt
model input height=640, width=640, channel=3
Rga built version:1.04 2134dde+2021-05-18 11:00:36
once run use 77.443000 ms
loadLabelName /home/toybrick/workspace/rockchip_yolov5/model/coco_80_labels_list.txt
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
@ (1128 74 1280 532) 0.326754
@ (668 41 892 525) 0.373704
@ (26 20 224 529) 0.398172
@ (1126 38 1278 284) 0.398172
@ (914 47 1112 532) 0.349865
@ (216 67 414 578) 0.326754
@ (186 0 438 319) 0.423160
@ (858 29 1080 300) 0.398172
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
loop count = 10 , average run 84.673900 ms
yolov5 C++代码代码地址
https://github.com/rockchip-linux/rknpu.git
/rknn/rknn_api/example/rknn_yolov5_demo
rknn 模型使用
rknpu/rknn/rknn_api/examples)/rknn_yolov5_demo/model/rk180x/yolov5s_relu_rk180x_out_opt.rknn 地址
yolov5s_relu_rk180x_out_opt.rknn
)
https://github.com/EASY-EAI/yolov5.git
转换模型
代码调整
替换rknn初始化rknn_init改为rknn_init2指定npu设备号
rknn_init_extend rknnInitExtend;
rknnInitExtend.;
ret = rknn_init2(&ctx, model_data, model_data_size, 0,&rknnInitExtend);
rknn_api 调整
在yolov5 C++demo代码的CMakeFileLists.txt文件中使用系统自带的librknn_api.so文件
link_libraries(
/usr/lib/aarch64-linux-gnu/librknn_api.so
......
)
编译RGA(可选)
本人使用板子rk3399proD没有自带的librga.so文件故需要编译rga
代码地址
https://github.com/rockchip-linux/linux-rga.git
编译调整
原因:在瑞芯微yolov5demo代码中通过dlsym使用c_RkRgaInit,c_RkRgaDeInit,c_RkRgaBlit函数,瑞芯微开源的RGA默认编译不含该函数
CMakeFileList.txt文件增加如下信息
set(IM2D_SRCS
core/RockchipRga.cpp
core/GrallocOps.cpp
core/NormalRga.cpp
core/RgaApi.cpp --------此处为新增
core/NormalRgaApi.cpp
core/RgaUtils.cpp
im2d_api/im2d.cpp)
运行结果
img width = 1280, img height = 720
Loading mode...
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI: API: 1.4.0 (bbe0dfc build: 2020-09-14 14:06:05)
D RKNNAPI: DRV: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
D RKNNAPI: ==============================================
sdk version: 1.4.0 (bbe0dfc build: 2020-09-14 14:06:05) driver version: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
model input num: 1, output num: 3
index=0 name=images_165 n_dims=4 dims=[1 3 640 640] n_elems=1228800 size=1228800 fmt=0 type=3 qnt_type=2 fl=0 zp=0 scale=0.003922
index=0 name=Conv_Conv_159/out0_0 n_dims=4 dims=[1 255 80 80] n_elems=1632000 size=1632000 fmt=0 type=3 qnt_type=2 fl=0 zp=187 scale=0.127843
index=1 name=Conv_Conv_160/out0_1 n_dims=4 dims=[1 255 40 40] n_elems=408000 size=408000 fmt=0 type=3 qnt_type=2 fl=0 zp=182 scale=0.113217
index=2 name=Conv_Conv_161/out0_2 n_dims=4 dims=[1 255 20 20] n_elems=102000 size=102000 fmt=0 type=3 qnt_type=2 fl=0 zp=172 scale=0.103272
model is NCHW input fmt
model input height=640, width=640, channel=3
Rga built version:1.04 2134dde+2021-05-18 11:00:36
once run use 77.443000 ms
loadLabelName /home/toybrick/workspace/rockchip_yolov5/model/coco_80_labels_list.txt
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
@ (1128 74 1280 532) 0.326754
@ (668 41 892 525) 0.373704
@ (26 20 224 529) 0.398172
@ (1126 38 1278 284) 0.398172
@ (914 47 1112 532) 0.349865
@ (216 67 414 578) 0.326754
@ (186 0 438 319) 0.423160
@ (858 29 1080 300) 0.398172
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
result 0: (1128, 74, 1280, 532), horse
result 1: ( 668, 41, 892, 525), horse
result 2: ( 26, 20, 224, 529), horse
result 6: (1126, 38, 1278, 284), person
result 10: ( 914, 47, 1112, 532), horse
result 13: ( 216, 67, 414, 578), horse
result 23: ( 186, 0, 438, 319), person
result 37: ( 858, 29, 1080, 300), person
loop count = 10 , average run 84.673900 ms
yolov5 C++代码代码地址
https://github.com/rockchip-linux/rknpu.git
/rknn/rknn_api/example/rknn_yolov5_demo
rknn 模型使用
rknpu/rknn/rknn_api/examples)/rknn_yolov5_demo/model/rk180x/yolov5s_relu_rk180x_out_opt.rknn 地址
yolov5s_relu_rk180x_out_opt.rknn
)
https://github.com/EASY-EAI/yolov5.git
转换模型
代码调整
替换rknn初始化rknn_init改为rknn_init2指定npu设备号
rknn_init_extend rknnInitExtend;
rknnInitExtend.;
ret = rknn_init2(&ctx, model_data, model_data_size, 0,&rknnInitExtend);
rknn_api 调整
在yolov5 C++demo代码的CMakeFileLists.txt文件中使用系统自带的librknn_api.so文件
link_libraries(
/usr/lib/aarch64-linux-gnu/librknn_api.so
......
)
编译RGA(可选)
本人使用板子rk3399proD没有自带的librga.so文件故需要编译rga
代码地址
https://github.com/rockchip-linux/linux-rga.git
编译调整
原因:在瑞芯微yolov5demo代码中通过dlsym使用c_RkRgaInit,c_RkRgaDeInit,c_RkRgaBlit函数,瑞芯微开源的RGA默认编译不含该函数
CMakeFileList.txt文件增加如下信息
set(IM2D_SRCS
core/RockchipRga.cpp
core/GrallocOps.cpp
core/NormalRga.cpp
core/RgaApi.cpp --------此处为新增
core/NormalRgaApi.cpp
core/RgaUtils.cpp
im2d_api/im2d.cpp)
举报
更多回帖
rotate(-90deg);
回复
相关问答
深度学习
RK3399
有没有
瑞
芯
微
RK3399
芯片参数,及
RK3399
盒子方案?
2021-07-19
3563
瑞
芯
微
RK3399
如何在Android10下配置WIFI?
2022-03-04
1581
YOLOv5
s算法在
RK3399
ProD上的部署推理流程是怎样的
2022-02-11
3068
瑞
芯
微
主控芯片必须要搭配原厂的电源管理IC吗
2022-06-10
2179
ASUS华硕tinker board 2S
瑞
芯
微
RK3399
开发板怎么样?
2022-03-07
1133
瑞
芯
微
RK3399
Pro的威廉希尔官方网站 板,电脑能识别为MASKROM设备,镜像文件烧录提示“Download Boot Failed”,请问各位是怎么回事?
2023-08-22
4479
求
大佬
分享
RK3399
的DRM应用例程
2022-03-07
1262
VS-
RK3399
超强七大性能优势
2021-02-05
2093
请大神全面分析对比 一下i.mx8quadmax和
rk3399
pro的优缺点
2020-03-09
4890
RK3399
是什么?
RK3399
的性能有哪些呢
2022-01-14
2603
发帖
登录/注册
20万+
工程师都在用,
免费
PCB检查工具
无需安装、支持浏览器和手机在线查看、实时共享
查看
点击登录
登录更多精彩功能!
英国威廉希尔公司网站
william hill官网 版块
小组
免费开发板试用
ebook
直播
搜索
登录
×
20
完善资料,
赚取积分