flyfish
安装Windows版的Rockchip RKNN-Toolkit 可以使用anaconda简化安装,如果是linux请参考
瑞芯微 Rockchip RKNN-Toolkit 环境搭建
Windows下已经安装Rockchip RKNN-Toolkit
物理上先通过Micro-USB 线或者USB Type-C 线 将 RK3399Pro, RK1808, RV1109, RV1126 任意一种开发板连接到PC,这里RV1126为例连接到windows系统 (win10 或者 win 11测试通过)
修改文件/etc/init.d/.usb_config,增加usb_ntb_en,然后重启开发板。
操作步骤
vi /etc/init.d/.usb_config
按i插入数据usb_ntb_en,再按ESC,输入 :wq保存退出
.usb_config文件内容如下
usb_adb_en
usb_ntb_en
目录是
rknn-toolkit-1.7.1\platform-tools\drivers_installer\windows-x86_64
列出 所连接设备的 ID
python3 -m rknn.bin.list_device
或者
python -m rknn.bin.list_devices
*************************
all device(s) with ntb mode:
1234d7a824f01234
*************************
也可以使用adb获取
adb下载地址
Windows版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Linux版本:https://dl.google.com/android/repository/platform-tools-latest-linux.zip
PS E:\platform-tools_r33.0.3-windows\platform-tools> ./adb devices
List of devices attached
1234d7a824f01234 device
以rknn-toolkit-1.7.1\examples\pytorch\resnet18\test.py
更改代码使其连接到开发板中
1 模型配置部分
print('--> Config model')
rknn.config(
reorder_channel='0 1 2',
mean_values=[[123.675, 116.28, 103.53]],
std_values=[[58.395, 58.395, 58.395]],
optimization_level=3,
target_platform='rv1126',
quantize_input_node= True,
output_optimize=1,
force_builtin_perm=_force_builtin_perm)
print('done')
2 初始化runtime部分
# Init runtime environment
print('--> Init runtime environment')
ret = rknn.init_runtime('rv1126', device_id='1234d7a824f01234')
if ret != 0:
print('Init runtime environment failed')
exit(ret)
print('done')
执行python test.py
结果
--> Export RKNN model
done
--> Init runtime environment
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI: API: 1.7.1 (566a9b6 build: 2021-10-28 15:13:57)
D RKNNAPI: DRV: 1.7.1 (0cfd4a1 build: 2021-11-24 09:33:04)
D RKNNAPI: ==============================================
done
--> Running model
-----TOP 5-----
[812]: 0.9993903636932373
[404]: 0.0004593881603796035
[657 833]: 2.9284470656421036e-05
[657 833]: 2.9284470656421036e-05
[895]: 1.850889384513721e-05
done