0. 创建虚拟环境
#!< 创建虚拟环境yolov8
$ sudo pip install virtualenv
$ sudo pip install virtualenvwrapper
$ mkvirtualenv yolov8 -p /usr/bin/python3.8
1. 将yolov8n-seg.pt转换为yolov8n-seg.onnx文件
#!< 创建项目目录yolov8-rknn并下载yolov8n-seg.pt模型文件
(yolov8) $ mkdir -p /home/tianzx/Github/yolov8-rknn/epbox/model/
(yolov8) $ cd /home/tianzx/Github/yolov8-rknn/epbox/model/
(yolov8) $ wget https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n-seg.pt
#!< 将yolov8n-seg.pt转换为yolov8n-seg.onnx
(yolov8) $ cd /home/tianzx/Github/yolov8-rknn/
(yolov8) $ git clone https://github.com/airockchip/ultralytics_yolov8.git
(yolov8) $ cd ultralytics_yolov8
(yolov8) $ vi ./ultralytics/cfg/default.yaml
model: /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.pt # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
(yolov8) $ export PYTHONPATH=./
(yolov8) $ python ./ultralytics/engine/exporter.py
......
Ultralytics YOLOv8.0.151 🚀 Python-3.8.10 torch-2.1.0+cu121 CPU ()
YOLOv8n-seg summary (fused): 195 layers, 3404320 parameters, 0 gradients, 12.6 GFLOPs
PyTorch: starting from '/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.pt' with input shape (16, 3, 640, 640) BCHW and output shape(s) ((16, 64, 80, 80), (16, 80, 80, 80), (16, 1, 80, 80), (16, 32, 80, 80), (16, 64, 40, 40), (16, 80, 40, 40), (16, 1, 40, 40), (16, 32, 40, 40), (16, 64, 20, 20), (16, 80, 20, 20), (16, 1, 20, 20), (16, 32, 20, 20), (16, 32, 160, 160)) (6.7 MB)
RKNN: starting export with torch 2.1.0+cu121...
RKNN: feed /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx to RKNN-Toolkit or RKNN-Toolkit2 to generate RKNN model.
Refer https://github.com/airockchip/rknn_model_zoo/tree/main/models/CV/object_detection/yolo
RKNN: export success ✅ 0.3s, saved as '/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx' (13.0 MB)
Export complete (2.2s)
Results saved to /home/tianzx/Github/yolov8_rknn/epbox/model
Predict: yolo predict task=segment model=/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx imgsz=640
Validate: yolo val task=segment model=/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx imgsz=640 data=coco.yaml
Visualize: https://netron.app
2. 将yolov8n-seg.onnx转换为yolov8n-seg-3588.rknn
# 安装rknn-toolkit2
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn/
(yolov8) $ git clone https://github.com/airockchip/rknn-toolkit2.git --depth 1
(yolov8) $ cd rknn-toolkit2/rknn-toolkit2/
(yolov8) $ pip install -r packages/requirements_cp38-2.0.0b0.txt
(yolov8) $ pip install packages/rknn_toolkit2-2.0.0b0+9bab5682-cp38-cp38-linux_x86_64.whl
#!< 3588 主板 只能使用v1.6.0版本 ☆☆☆☆☆
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn
(yolov8) $ git clone -b v1.6.0 --depth=1 https://github.com/airockchip/rknn_model_zoo.git
(yolov8) $ cd rknn_model_zoo/examples/yolov8_seg/python
(yolov8) $ python convert.py /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx rk3588 i8 /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg-3588.rknn
I rknn-toolkit2 version: 2.0.0b0+9bab5682
--> Config model
done
--> Loading model
I It is recommended onnx opset 19, but your onnx model opset is 12!
I Model converted from pytorch, 'opset_version' should be set 19 in torch.onnx.export for successful convert!
I Loading : 100%|██████████████████████████████████████████████| 162/162 [00:00<00:00, 50331.65it/s]
done
--> Building model
W build: found outlier value, this may affect quantization accuracy
const name abs_mean abs_std outlier value
model.22.cv3.1.1.conv.weight 0.12 0.18 -12.310
I GraphPreparing : 100%|████████████████████████████████████████| 183/183 [00:00<00:00, 8442.40it/s]
I Quantizating : 100%|████████████████████████████████████████████| 183/183 [00:05<00:00, 35.36it/s]
W build: The default input dtype of 'images' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '375' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of 'onnx::ReduceSum_383' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '388' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '354' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '395' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of 'onnx::ReduceSum_403' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '407' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '361' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '414' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of 'onnx::ReduceSum_422' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '426' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '368' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
W build: The default output dtype of '347' is changed from 'float32' to 'int8' in rknn model for performance!
Please take care of this change when deploy rknn model with Runtime API!
I rknn building ...
I rknn buiding done.
done
--> Export rknn model
--> The RKNN model saved in: /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg-3588.rknn
done
3. 测试onnx模型和rknn模型
3.1 测试onnx模型
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn/
(yolov8) $ cd rknn_model_zoo/examples/yolov8_seg/python/
(yolov8) $ python yolov8_seg.py --model_path /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx --img_show
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/py_utils/onnx_executor.py:12: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
if getattr(np, 'bool', False):
Model-/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg.onnx is onnx model, starting val
infer 1/1
IMG: bus.jpg
person @ (209 241 285 510) 0.867
bus @ (95 137 558 440) 0.867
person @ (109 235 224 535) 0.842
person @ (476 232 560 520) 0.801
3.2 测试rknn模型
3588安卓主板如果要调用rknn模型,需要更新3588安卓主板内的 rknn_server 和 librknnrt.so 文件。
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn/
(yolov8) $ cd rknn-toolkit2/rknpu2/
# 切换到 root 用户权限
(yolov8) $ adb root
# 挂载文件系统为可读写模式
(yolov8) $ adb remount
(yolov8) $ adb shell
rk3588_s:/ # cd /vendor/bin/
# 我这边3588安卓主板的rknn_server 和 librknnrt.so 均是1.5.0版本, arm64架构
rk3588_s:/ # cp rknn_server rknn_server.1.5.0
rk3588_s:/ # cd ../lib64
rk3588_s:/ # cp librknnrt.so librknnrt.so.1.5.0
rk3588_s:/ # exit
(yolov8) $ adb push runtime/Android/rknn_server/arm64/rknn_server /vendor/bin/
runtime/Android/rknn_server/arm64/rknn_server: 1 file pushed, 0 skipped. 227.7 MB/s (895216 bytes in 0.004s)
(yolov8) $ adb push runtime/Android/librknn_api/arm64-v8a/librknnrt.so /vendor/lib64/
runtime/Android/librknn_api/arm64-v8a/librknnrt.so: 1 file pushed, 0 skipped. 465.1 MB/s (7366800 bytes in 0.015s)
(yolov8) $ adb shell
rk3588_s:/ # chmod +x /vendor/bin/rknn_server
rk3588_s:/ # su
rk3588_s:/ # setenforce 0
rk3588_s:/ # /vendor/bin/rknn_server &
[1] 3895
rk3588_s:/ # start rknn server, version:2.0.0b0 (18eacd0 build@2024-03-22T14:07:01)
rk3588_s:/ # exit
(yolov8) $ cd ~/Github/yolov8_rknn/rknn_model_zoo/examples/yolov8_seg/python
(yolov8) $ python yolov8_seg.py --model_path /home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg-3588.rknn --target rk3588 --img_show
I rknn-toolkit2 version: 2.0.0b0+9bab5682
--> Init runtime environment
adbd is already running as root
I target set by user is: rk3588
I Get hardware info: target_platform = rk3588, os = Android, aarch = aarch64
I Check RK3588 board npu runtime version
I Starting ntp or adb, target is RK3588
I Start adb...
I Connect to Device success!
I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:36)
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI: API: 2.0.0b0 (18eacd0 build@2024-03-22T06:07:59)
D RKNNAPI: DRV: rknn_server: 2.0.0b0 (18eacd0 build@2024-03-22T14:07:01)
D RKNNAPI: DRV: rknnrt: 2.0.0b0 (35a6907d79@2024-03-24T10:30:08)
D RKNNAPI: ==============================================
D RKNNAPI: Input tensors:
D RKNNAPI: index=0, name=images, n_dims=4, dims=[1, 640, 640, 3], n_elems=1228800, size=1228800, w_stride = 0, size_with_stride = 0, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
D RKNNAPI: Output tensors:
D RKNNAPI: index=0, name=375, n_dims=4, dims=[1, 64, 80, 80], n_elems=409600, size=409600, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-55, scale=0.138304
D RKNNAPI: index=1, name=onnx::ReduceSum_383, n_dims=4, dims=[1, 80, 80, 80], n_elems=512000, size=512000, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.002873
D RKNNAPI: index=2, name=388, n_dims=4, dims=[1, 1, 80, 80], n_elems=6400, size=6400, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003169
D RKNNAPI: index=3, name=354, n_dims=4, dims=[1, 32, 80, 80], n_elems=204800, size=204800, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=26, scale=0.023277
D RKNNAPI: index=4, name=395, n_dims=4, dims=[1, 64, 40, 40], n_elems=102400, size=102400, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-40, scale=0.095424
D RKNNAPI: index=5, name=onnx::ReduceSum_403, n_dims=4, dims=[1, 80, 40, 40], n_elems=128000, size=128000, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003418
D RKNNAPI: index=6, name=407, n_dims=4, dims=[1, 1, 40, 40], n_elems=1600, size=1600, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
D RKNNAPI: index=7, name=361, n_dims=4, dims=[1, 32, 40, 40], n_elems=51200, size=51200, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=32, scale=0.020263
D RKNNAPI: index=8, name=414, n_dims=4, dims=[1, 64, 20, 20], n_elems=25600, size=25600, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-43, scale=0.075364
D RKNNAPI: index=9, name=onnx::ReduceSum_422, n_dims=4, dims=[1, 80, 20, 20], n_elems=32000, size=32000, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003874
D RKNNAPI: index=10, name=426, n_dims=4, dims=[1, 1, 20, 20], n_elems=400, size=400, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
D RKNNAPI: index=11, name=368, n_dims=4, dims=[1, 32, 20, 20], n_elems=12800, size=12800, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=26, scale=0.022538
D RKNNAPI: index=12, name=347, n_dims=4, dims=[1, 32, 160, 160], n_elems=819200, size=819200, w_stride = 0, size_with_stride = 0, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-119, scale=0.029378
done
Model-/home/tianzx/Github/yolov8_rknn/epbox/model/yolov8n-seg-3588.rknn is rknn model, starting val
W inference: The 'data_format' is not set, and its default value is 'nhwc'!
IMG: bus.jpg
person @ (209 240 285 509) 0.868
bus @ (94 137 557 439) 0.841
person @ (108 235 221 536) 0.829
person @ (475 233 560 521) 0.783
查看3588安卓主板的基本信息,这里需要用到 adb
命令,需要自行安装,比如我这边系统的adb路径为: /home/tianzx/Android/Sdk/platform-tools/adb
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn/
#!< 安卓主板返回数字
(yolov8) $ adb shell getprop ro.build.version.release
12
#!< 如果板端是 Android 系统,可以在计算机端执行以下命令查询系统架构:
# 该命令的输出信息参考如下,其中 arm64-v8a 表示 ARM 64 位架构、第八版本的 ABI。
(yolov8) $ adb shell getprop ro.product.cpu.abi
arm64-v8a
#!< 查看RKNPU2驱动版本信息
# rknpu 0.8.8 20230428
(yolov8) $ adb shell
rk3588_s:/ # dmesg | grep -i rknpu
[ 4.875203] RKNPU fdab0000.npu: Adding to iommu group 0
[ 4.875369] RKNPU fdab0000.npu: RKNPU: rknpu iommu is enabled, using iommu mode
[ 4.876734] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdab0000-0xfdabffff]
[ 4.876759] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdac0000-0xfdacffff]
[ 4.876777] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdad0000-0xfdadffff]
[ 4.877338] [drm] Initialized rknpu 0.8.8 20230428 for fdab0000.npu on minor 1
[ 4.881011] RKNPU fdab0000.npu: RKNPU: bin=0
[ 4.881195] RKNPU fdab0000.npu: leakage=8
[ 4.881248] debugfs: Directory 'fdab0000.npu-rknpu' with parent 'vdd_npu_s0' already present!
[ 4.889245] RKNPU fdab0000.npu: pvtm=855
[ 4.894164] RKNPU fdab0000.npu: pvtm-volt-sel=2
[ 4.895645] RKNPU fdab0000.npu: avs=0
[ 4.895857] RKNPU fdab0000.npu: l=10000 h=85000 hyst=5000 l_limit=0 h_limit=800000000 h_table=0
[ 4.907412] RKNPU fdab0000.npu: failed to find power_model node
[ 4.907459] RKNPU fdab0000.npu: RKNPU: failed to initialize power model
[ 4.907473] RKNPU fdab0000.npu: RKNPU: failed to get dynamic-coefficient
#!< 启动rknn_server服务
rk3588_s:/ # su
rk3588_s:/ # setenforce 0
rk3588_s:/ # /vendor/bin/rknn_server &
# 可以看到rknn_server已经更新版本为 2.0.0b0
rk3588_s:/ # start rknn server, version:2.0.0b0 (18eacd0 build@2024-03-22T14:07:01)
# 查询 librknnrt.so 库版本
# 64 位系统 [已更新64位librknnrt.so文件,版本信息为2.0.0b0
rk3588_s:/ # strings /vendor/lib64/librknnrt.so | grep -i "librknnrt version"
librknnrt version: 2.0.0b0 (35a6907d79@2024-03-24T10:30:08)
# 32 位系统 [未更新32位librknnrt.so文件,版本信息为1.5.0]
rk3588_s:/ # strings /vendor/lib/librknnrt.so | grep -i "librknnrt version"
librknnrt version: 1.5.0 (e6fe0c678@2023-05-25T08:09:02)
4. 3588安卓主板apk测试
(yolov8) $ cd /home/tianzx/Github/yolov8_rknn/rknn_model_zoo
#!< https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip
(yolov8) $ export ANDROID_NDK_PATH=/home/tianzx/Android/Sdk/ndk/android-ndk-r19c/
(yolov8) $ chmod +x build-android.sh
(yolov8) $ ./build-android.sh -t rk3588 -a arm64-v8a -d yolov8_seg
===================================
BUILD_DEMO_NAME=yolov8_seg
BUILD_DEMO_PATH=examples/yolov8_seg/cpp
TARGET_SOC=rk3588
TARGET_ARCH=arm64-v8a
BUILD_TYPE=Release
ENABLE_ASAN=OFF
INSTALL_DIR=/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo
BUILD_DIR=/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/build/build_rknn_yolov8_seg_demo_rk3588_android_arm64-v8a_Release
ANDROID_NDK_PATH=/home/tianzx/Android/Sdk/ndk/android-ndk-r19c/
===================================
-- Android: Targeting API '23' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 8.0.2
-- The CXX compiler identification is Clang 8.0.2
-- Check for working C compiler: /home/tianzx/Android/Sdk/ndk/android-ndk-r19c//toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/tianzx/Android/Sdk/ndk/android-ndk-r19c//toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/tianzx/Android/Sdk/ndk/android-ndk-r19c//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/tianzx/Android/Sdk/ndk/android-ndk-r19c//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 64bit
-- Found OpenCV: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/3rdparty/opencv/opencv-android-sdk-build (found version "3.4.5")
-- OpenCV_DIR=/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/examples/yolov8_seg/cpp/../../../3rdparty/opencv/opencv-android-sdk-build/sdk/native/jni/abi-arm64-v8a
-- OpenCV_LIBS=opencv_calib3dopencv_coreopencv_features2dopencv_imgcodecsopencv_imgproc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/build/build_rknn_yolov8_seg_demo_rk3588_android_arm64-v8a_Release
Scanning dependencies of target fileutils
Scanning dependencies of target imageutils
Scanning dependencies of target imagedrawing
[ 10%] Building C object utils.out/CMakeFiles/fileutils.dir/file_utils.c.o
[ 20%] Building C object utils.out/CMakeFiles/imageutils.dir/image_utils.c.o
[ 30%] Building C object utils.out/CMakeFiles/imagedrawing.dir/image_drawing.c.o
[ 40%] Linking C static library libfileutils.a
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/utils/image_utils.c:282:35: warning: passing 'const image_buffer_t *' to parameter of type 'image_buffer_t *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
int size = get_image_size(img);
^~~
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/utils/image_utils.h:67:36: note: passing argument to parameter 'image' here
int get_image_size(image_buffer_t* image);
^
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/utils/image_utils.c:626:15: warning: incompatible pointer types initializing 'char *' with an expression of type 'int *' [-Wincompatible-pointer-types]
char* p_imcolor = &imcolor;
^ ~~~~~~~~
[ 40%] Built target fileutils
[ 50%] Linking C static library libimagedrawing.a
[ 50%] Built target imagedrawing
2 warnings generated.
[ 60%] Linking C static library libimageutils.a
[ 60%] Built target imageutils
Scanning dependencies of target rknn_yolov8_seg_demo
[ 70%] Building CXX object CMakeFiles/rknn_yolov8_seg_demo.dir/rknpu2/yolov8_seg.cc.o
[ 80%] Building CXX object CMakeFiles/rknn_yolov8_seg_demo.dir/postprocess.cc.o
[ 90%] Building CXX object CMakeFiles/rknn_yolov8_seg_demo.dir/main.cc.o
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/examples/yolov8_seg/cpp/postprocess.cc:925:16: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
return "null";
^
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/examples/yolov8_seg/cpp/postprocess.cc:933:12: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
return "null";
^
2 warnings generated.
[100%] Linking CXX executable rknn_yolov8_seg_demo
[100%] Built target rknn_yolov8_seg_demo
[ 20%] Built target fileutils
[ 40%] Built target imageutils
[ 60%] Built target imagedrawing
[100%] Built target rknn_yolov8_seg_demo
Install the project...
-- Install configuration: "Release"
-- Installing: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/./rknn_yolov8_seg_demo
-- Installing: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/lib/librknnrt.so
-- Installing: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/model/bus.jpg
-- Installing: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/model/coco_80_labels_list.txt
-- Up-to-date: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/lib/librknnrt.so
-- Installing: /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/lib/librga.so
The RKNN model can not be found in "/home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/model", please check!
(yolov8) $ cp ../epbox/model/yolov8n-seg-3588.rknn install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/model/
(yolov8) $ ls -hl /home/tianzx/Github/yolov8_rknn/rknn_model_zoo/install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/model/
total 4.7M
-rw-r--r-- 1 tianzx tianzx 178K 4月 17 15:36 bus.jpg
-rw-r--r-- 1 tianzx tianzx 621 4月 17 15:36 coco_80_labels_list.txt
-rw-rw-r-- 1 tianzx tianzx 4.6M 4月 17 17:59 yolov8n-seg-3588.rknn
(yolov8) $ adb root
adbd is already running as root
(yolov8) $ adb remount
remount succeeded
(yolov8) $ adb push install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo /data/
install/rk3588_android_arm64-v8a/rknn_yolov8_seg_demo/: 6 files pushed, 0 skipped. 73.0 MB/s (30818071 bytes in 0.403s)
(yolov8) $ adb shell
rk3588_s:/ # cd data/rknn_yolov8_seg_demo/
rk3588_s:/data/rknn_yolov8_seg_demo # export LD_LIBRARY_PATH=./lib
rk3588_s:/data/rknn_yolov8_seg_demo # ./rknn_yolov8_seg_demo model/yolov8n-seg-3588.rknn model/bus.jpg
load lable ./model/coco_80_labels_list.txt
model input num: 1, output num: 13
input tensors:
index=0, name=images, n_dims=4, dims=[1, 640, 640, 3], n_elems=1228800, size=1228800, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
output tensors:
index=0, name=375, n_dims=4, dims=[1, 64, 80, 80], n_elems=409600, size=409600, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-55, scale=0.138304
index=1, name=onnx::ReduceSum_383, n_dims=4, dims=[1, 80, 80, 80], n_elems=512000, size=512000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.002873
index=2, name=388, n_dims=4, dims=[1, 1, 80, 80], n_elems=6400, size=6400, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003169
index=3, name=354, n_dims=4, dims=[1, 32, 80, 80], n_elems=204800, size=204800, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=26, scale=0.023277
index=4, name=395, n_dims=4, dims=[1, 64, 40, 40], n_elems=102400, size=102400, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-40, scale=0.095424
index=5, name=onnx::ReduceSum_403, n_dims=4, dims=[1, 80, 40, 40], n_elems=128000, size=128000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003418
index=6, name=407, n_dims=4, dims=[1, 1, 40, 40], n_elems=1600, size=1600, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
index=7, name=361, n_dims=4, dims=[1, 32, 40, 40], n_elems=51200, size=51200, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=32, scale=0.020263
index=8, name=414, n_dims=4, dims=[1, 64, 20, 20], n_elems=25600, size=25600, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-43, scale=0.075364
index=9, name=onnx::ReduceSum_422, n_dims=4, dims=[1, 80, 20, 20], n_elems=32000, size=32000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003874
index=10, name=426, n_dims=4, dims=[1, 1, 20, 20], n_elems=400, size=400, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
index=11, name=368, n_dims=4, dims=[1, 32, 20, 20], n_elems=12800, size=12800, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=26, scale=0.022538
index=12, name=347, n_dims=4, dims=[1, 32, 160, 160], n_elems=819200, size=819200, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-119, scale=0.029378
model is NHWC input fmt
model input height=640, width=640, channel=3
origin size=640x640 crop size=640x640
input image: 640 x 640, subsampling: 4:2:0, colorspace: YCbCr, orientation: 1
scale=1.000000 dst_box=(0 0 639 639) allow_slight_change=1 _left_offset=0 _top_offset=0 padding_w=0 padding_h=0
src width=640 height=640 fmt=0x1 virAddr=0x0xb400007585f0b000 fd=0
dst width=640 height=640 fmt=0x1 virAddr=0x0xb400007585ddc000 fd=0
src_box=(0 0 639 639)
dst_box=(0 0 639 639)
color=0x72
rga_api version 1.10.0_[2]
rknn_run
person @ (209 240 285 509) 0.868
bus @ (94 137 557 439) 0.841
person @ (108 235 221 536) 0.829
person @ (475 233 560 521) 0.783
write_image path: out.png width=640 height=640 channel=3 data=0xb400007585f0b000
rk3588_s:/data/rknn_yolov8_seg_demo # exit
(yolov8) $ adb pull /data/rknn_yolov8_seg_demo/out.png
/data/rknn_yolov8_seg_demo/out.png: 1 file pulled, 0 skipped. 36.2 MB/s (692055 bytes in 0.018s)
(yolov8) $ pwd
/home/tianzx/Github/yolov8_rknn/rknn_model_zoo
5. 参考连接
- ultralytics_yolov8
- yolov8/README.md
- yolov8_seg/README.md
- rknn-toolkit2/issues/10