4091 views|2 replies

10

Posts

0

Resources
The OP
 

#AIChallengeCampSecondStation#onxx model converted to rknn model [Copy link]

1. Environment construction:

Install rknn-toolkit and its corresponding dependent libraries

链接已隐藏,如需查看请登录或者注册

Install the corresponding dependent libraries and rknn-toolkit tools according to 01_Rockchip_RKNPU_Quick_Start_RKNN_SDK_V2.0.0beta0_CN.pdf in the doc directory

2. Model Conversion

Use the downloaded rknn_model_zoo, \examples\yolov5\python\convert.py python file to convert the model

Execute python3 convert.py ../model/test1.onnx rv1106 i8 ../model/test.rknn

Error

encountered

Follow the prompts to optimize the script of the first station and regenerate the onxx model

Changed from

to

Then regenerate the onxx model and execute python3 convert.py ../model/test1.onnx rv1106 i8 ../model/test.rknn again to complete the conversion successfully.

Source code:

import sys

from rknn.api import RKNN

DATASET_PATH = '../../../datasets/COCO/coco_subset_20.txt'
DEFAULT_RKNN_PATH = '../model/test.rknn'
DEFAULT_QUANT = True

def parse_arg():
if len(sys.argv) < 3:
print("Usage: python3 {} onnx_model_path [platform] [dtype(optional)] [output_rknn_path(optional)]".format(sys.argv[0]) )
print(" platform choose from [rk3562,rk3566,rk3568,rk3588,rk1808,rv1109,rv1126]") print
(" dtype choose from [i8, fp] for [rk3562,rk3566,rk3568,rk3588]")
print(" dtype choose from [u8, fp] for [rk1808,rv1109,rv1126]")
exit(1)

model_path = sys.argv[1]
platform = sys.argv[2]

do_quant = DEFAULT_QUANT
if len(sys.argv) > 3:
model_type = sys.argv[3]
if model_type not in ['i8', 'u8', 'fp']:
print("ERROR: Invalid model type: {} ".format(model_type))
exit(1)
elif model_type in ['i8', 'u8']:
do_quant = True
else:
do_quant = False

if len(sys.argv) > 4:
output_path = sys.argv[4]
else:
output_path = DEFAULT_RKNN_PATH

return model_path, platform, do_quant, output_path

if __name__ == '__main__':
model_path, platform, do_quant, output_path = parse_arg()

# Create RKNN object
rknn = RKNN(verbose=False)

# Pre-process config
print('--> Config model')
rknn.config(mean_values=[[0, 0, 0]], std_values=[
[255, 255, 255]], target_platform=platform)
print(' done')

# Load model
print('--> Loading model')
ret = rknn.load_onnx(model=model_path)
if ret != 0:
print('Load model failed!')
exit(ret)
print('done')

# Build model
print('--> Building model')
ret = rknn.build(do_quantization=do_quant, dataset=DATASET_PATH)
if ret != 0:
print('Build model failed!')
exit(ret)
print('done ')

# Export rknn model
print('--> Export rknn model')
ret = rknn.export_rknn(output_path)
if ret != 0:
print('Export rknn model failed!')
exit(ret)
print('done')

# Release
rknn.release()

appendix:

20240514131458170.pdf

5.06 MB, downloads: 1

售价: 4 分芯积分  [记录]

test.rknn

433.91 KB, downloads: 1

This post is from Embedded System

Latest reply

I checked it immediately and found that not writing the full name of this abbreviation is harmful... It turns out that RKNN is not the nearest neighbor at all It turned out to be: Recurrent Kernel Neural Network, A new neural network...   Details Published on 2024-5-15 12:17

1115

Posts

1

Resources
2
 

KNN is the nearest neighbor, that is, find the K nearest neighbors, and then add these nearest neighbors to the category with the largest number of people (join the thigh)

What does the R in RKNN mean?

This post is from Embedded System

Comments

I immediately looked it up and found that it is harmful if you don’t write the full name of this abbreviation. It turns out that RKNN is not the nearest neighbor at all. It is: Recurrent Kernel Neural Network, a new type of neural network. Alas  Details Published on 2024-5-15 12:17
 
 

1115

Posts

1

Resources
3
 
hellokitty_bean posted on 2024-5-15 12:14 KNN is the nearest neighbor, that is, find the K nearest neighbors, and then these nearest neighbors are added to the category with the largest number of people (leaving the thigh...

I checked it immediately and found that not writing the full name of this abbreviation is harmful...

It turns out that RKNN is not the nearest neighbor at all

It turned out to be: Recurrent Kernel Neural Network,

A new neural network...

This post is from Embedded System
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list