创建RKNN-Toolkit2-2.0.0 Conda环境

创建RKNN-Toolkit2-2.0.0

conda create -n RKNN-Toolkit2-2.0.0 python=3.8

进入RKNN-Toolkit2-2.0.0

conda activate RKNN-Toolkit2-2.0.0

下载rknn-toolkit2

git clone https://github.com/airockchip/rknn-toolkit2.git

git clone https://github.com/airockchip/rknn-toolkit2.git
Cloning into 'rknn-toolkit2'...
remote: Enumerating objects: 2392, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 2392 (delta 54), reused 48 (delta 47), pack-reused 2313 (from 1)
Receiving objects: 100% (2392/2392), 2.31 GiB | 1.67 MiB/s, done.
Resolving deltas: 100% (847/847), done.
Updating files: 100% (1429/1429), done.

安装依赖

pip3 --default-timeout=500 install protobuf==3.20.3
pip3 --default-timeout=500 install psutil==5.9.0
pip3 --default-timeout=500 install ruamel.yaml==0.17.4
pip3 --default-timeout=500 install scipy==1.5.4
pip3 --default-timeout=500 install tqdm==4.64.0
pip3 --default-timeout=500 install opencv-python==4.5.5.64
pip3 --default-timeout=500 install fast-histogram==0.11
pip3 --default-timeout=500 install onnx==1.14.1
pip3 --default-timeout=500 install onnxoptimizer==0.2.7
pip3 --default-timeout=500 install onnxruntime==1.16.0
pip3 --default-timeout=500 install torch==1.10.1
pip3 --default-timeout=500 install tensorflow==2.8.0

继续安装

pip3 install packages/rknn_toolkit2-2.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Installing collected packages: rknn-toolkit2
Successfully installed rknn-toolkit2-2.2.0

验证安装

python3
Python 3.8.19 (default, Mar 20 2024, 19:58:24)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

from rknn.api import RKNN

如果导入 RKNN 模块没有失败,说明安装成功

下载模型转换项目
RKNN Model Zoo基于RKNPU SDK 工具链开发, 提供了目前主流算法的部署例程. 例程包含导出RKNN模型, 使用Python API, CAPI 推理RKNN 模型的流程

git clone https://github.com/airockchip/rknn_model_zoo.git

也可以直接下载包

wget https://github.com/airockchip/rknn_model_zoo/archive/refs/tags/v2.2.0.tar.gz

Cloning into 'rknn_model_zoo'...
remote: Enumerating objects: 2846, done.
remote: Counting objects: 100% (618/618), done.
remote: Compressing objects: 100% (241/241), done.
remote: Total 2846 (delta 433), reused 475 (delta 367), pack-reused 2228 (from 1)
Receiving objects: 100% (2846/2846), 271.73 MiB | 1.67 MiB/s, done.
Resolving deltas: 100% (949/949), done.
Updating files: 100% (1409/1409), done.

进入目录

rknn_model_zoo/examples/yolov8/model

运行download.sh下载yolov8n.onnx包

wget -O ./yolov8n.onnx https://ftrg.zbox.filez.com/v2/delivery/data/95f00b0fc900458ba134f8b180b3f7a1/examples/yolov8/yolov8n.onnx

进入rknn_model_zoo/examples/yolov8/python

python convert.py yolov8n.onnx rk3588 i8 yolov8n.rknn

I rknn-toolkit2 version: 2.2.0
--> Config model
done
--> Loading model
I Loading : 100%|██████████████████████████████████████████████| 126/126 [00:00<00:00, 35533.00it/s]
done
--> Building model
.....
I rknn building ...
I rknn buiding done.
done
--> Export rknn model
done

查看生成的模型

md5sum yolov8n.rknn
c43e16c3d1d1a316ef36e08652b75061 yolov8n.rknn

本文链接地址:https://const.net.cn/805.html

标签: none

添加新评论