Development environment Ubuntu 18.04
RKNN Toolkit tool download link: https://github.com/rockchip-linux/rknn-toolkit
Install RKNN Toolkit
pip3 install --user -r rknn-toolkit/packages/requirements-cpu.txt
pip3 install --user -U rknn-toolkit/packages/rknn_toolkit-1.4.0-cp36-cp36m-linux_x86_64.whl
Model conversion
cd rknn-toolkit/examples/rknn_convert
python rknn_convert.py /home/aaron/pro/tb/tb3/npu/rknn-toolkit-1.4.0/rknn-toolkit/examples/rknn_convert/models/tensorflow/mobilenet-ssd out_rknn False
The first parameter is the path of the original model to be converted (you can directly fill in the directory, but the directory needs to contain the `model_config.yml` file)
The second parameter is the output directory of the converted model
The third parameter is whether to enable pre-compilation (to speed up model loading time)
NPU model development board deployment
Take RK1808 as an example here
RKNN-Toolkit is connected to the hardware of the development board through the USB of the PC, and the constructed or imported RKNN model is transferred to RK1808 for operation, and the inference results and performance information are obtained from RK1808.
Perform the following steps
-
Make sure that the USB OTG of the development board is connected to the PC, and ADB can correctly identify the device, that is, you
adb devices -l
can see the target device when you execute the command on the PC . -
When calling the
init_runtime
interface to initialize the operating environment, you need to specify the target parameter and the device_id parameter. The target parameter indicates the hardware type, and the selected value isrk1808
. When the PC is connected to multiple devices, you also need to specify the device_id parameter, which is the device number, which can be viewed through theadb devics
command. -
Take
rknn-toolkit/example/mobilenet_v1
an example as follows:$ adb devices List of devices attached 0123456789ABCDEF device
I.e. changed to
ret = rknn.init_runtime(target='rk1808', device_id='0123456789ABCDEF')
-
run
python3 ./test.py
After running successfully, the data obtained after RK1808 inference can be obtained.