Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

其他模型可以使用此程序部署到k210吗 #55

Open
junze6 opened this issue May 6, 2022 · 13 comments
Open

其他模型可以使用此程序部署到k210吗 #55

junze6 opened this issue May 6, 2022 · 13 comments

Comments

@junze6
Copy link

junze6 commented May 6, 2022

我使用yolo-faster训练好的模型输出为[1,45,7,10],[1,45,14,20], 可以使用你的程序部署到k210吗

@junze6
Copy link
Author

junze6 commented May 6, 2022

我加载不了模型,是不是内存不够了。这是我转换成kmodel时,显示的
MEMORY USAGES
.input 840.00 KB (860160 B)
.output 61.52 KB (63000 B)
.data 3.28 MB (3440640 B)
MODEL 963.44 KB (986560 B)
TOTAL 5.10 MB (5350360 B)

@zhen8838
Copy link
Owner

zhen8838 commented May 9, 2022

可以的,你也可以参考yolox的程序. kmodel大可能有两个原因,一是因为模型本身大,二是因为有的层没有被量化. 你可以打开dump ir的选项检查最终的schedule结果,参考这里

@junze6
Copy link
Author

junze6 commented May 10, 2022

我使用yolo-fastestv2跑出来的pth转onnx再转kmodel,使用你的代码在部署模型时,卡在下面加载模型代码这里,是什么原因?

/* 初始化 kpu */
if(kpu_load_kmodel(&task, model_data_align) != 0)
{
printf("\nmodel init error\n");
while(1)
;
}

@junze6
Copy link
Author

junze6 commented May 10, 2022

onnx转成kmodel可以进行量化吗

@zhen8838
Copy link
Owner

你用的nncase是新版本的吗?加载模型失败可能需要去nncase release里面下载k210 runtime然后替换sdk中的runtime v1. 不过可能是kmodel太大等原因. 用nncase 编译模型的时候只要开启ptq的选项就可以量化了, 不论是onnx还是tflite.

@zhen8838
Copy link
Owner

你这个模型不到1mb, 应该也不是模型太大的问题. 你有尝试过在pc上加载模型进行验证吗? pc上的runtime和210的runtime是一套代码,如果pc上执行没问题, 210有问题,那你可能需要手动编译一下runtime,在load model函数中添加一些print去排查问题.

@junze6
Copy link
Author

junze6 commented May 11, 2022

我添加printf函数发现是nncase_load_kmodel()函数出问题,重新下载[kendryte-standalone-sdk],可以加载模型了,但是报了一些看不懂的错误,请问一下您知道这是什么原因吗
core dump: misaligned load
Cause 0x0000000000000004, EPC 0x000000008000567a
reg00 = 0x0000000000000000, reg01 = 0x0000000080005662
reg02 = 0x000000008045d9f0, reg03 = 0x0000000080426178
reg04 = 0x0000000080456ac0, reg05 = 0x0000000000000688
reg06 = 0x000000008000aa7a, reg07 = 0x89888787898a8a88
reg08 = 0x0000000080424818, reg09 = 0x000000008045dc30
reg10 = 0x0000000080424f78, reg11 = 0x0000000000000004
reg12 = 0x000000008045dc24, reg13 = 0x000000008045dc20
reg14 = 0xffffffffffffffff, reg15 = 0x0000000000000004
reg16 = 0x00000000000000ff, reg17 = 0x0000000000000040
reg18 = 0x00000000000000d2, reg19 = 0x0000000000000014
reg20 = 0x000000008045e954, reg21 = 0x00000000804e5fe0
reg22 = 0x00000000804e0dc0, reg23 = 0x00000000000000d2
reg24 = 0x00000000000000d2, reg25 = 0x000000000000004c
reg26 = 0x00000000000000d2, reg27 = 0x000000008005d100
reg28 = 0x0000000000000003, reg29 = 0x0000000000000000
reg30 = 0x8184817f84878382, reg31 = 0x8283828487838083

@zhen8838
Copy link
Owner

我后天去检查一下问题.

@zhen8838
Copy link
Owner

我重新测试了yolox的例子,但是并没有遇到无法加载的问题.你们使用的sdk是develop分支的吗?

@junze6
Copy link
Author

junze6 commented May 12, 2022

我使用的sdk版本是develop,onnx量化可以先经过onnxsim简化吗,为什么我量化失败了

@junze6
Copy link
Author

junze6 commented May 12, 2022

yolo-fastestv2的检测头将检测框的回归,前景背景的分类以及检测类别的分类解耦成3个不同的特征图,导出onnx时在通道维度合并了,这个有影响吗

@zhen8838
Copy link
Owner

量化失败的表现是什么? 我之前做过你这样的操作,先合并后处理再从里面切,最后也没有出现很大的精度损失,不过量化的问题最好还是给nncase提个issue.

@junze6
Copy link
Author

junze6 commented May 13, 2022

您好,我参考您的yolox的conpile再使用onnx-simplifier简化一下可以了,但是部署k210时,在kpu_run_kmodel()报了如下错误,是模型的原因吗

[..m/runtime_module.cpp:65 (shape_reg)] id < shape_regs_.size() = false (bool)
error: Result too large

The summary of the compiled model is

SUMMARY
INPUTS
0	new_input	u8[1,3,224,320]
OUTPUTS
0	output	f32[1,45,7,10]
1	650	f32[1,45,14,20]

MEMORY USAGES
.input	 210.00 KB	(215040 B)
.output	  61.52 KB	(63000 B)
.data	   2.05 MB	(2150400 B)
MODEL	 263.95 KB	(270288 B)
TOTAL	   2.57 MB	(2698728 B)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants