Toybrick

yolov4 tiny rknn conversion problem

rakidis

高级会员

积分
507
发表于 2020-7-23 18:49:01    查看: 7450|回复: 9 | [复制链接]    打印 | 显示全部楼层
Hello,

I encountered a problem while trying to convert yolov4 tiny to rknn model, using your visualization rknn tool.
https://raw.githubusercontent.co ... cfg/yolov4-tiny.cfg
https://github.com/AlexeyAB/dark ... yolov4-tiny.weights

E Catch exception when loading darknet model: /home/kadir/Desktop/rknn-toolkit-v1.3.0/yolov4-tiny.cfg!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 555, in rknn.api.rknn_base.RKNNBase.load_darknet
E   File "rknn/base/RKNNlib/converter/convert_darknet.py", line 685, in rknn.base.RKNNlib.converter.convert_darknet.Converter.load_blobs
E   File "rknn/base/RKNNlib/converter/convert_darknet.py", line 403, in rknn.base.RKNNlib.converter.convert_darknet.Convolution_Blob_Assign.assign
E   File "/home/kadir/anaconda3/envs/rknn/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 292, in reshape
E     return _wrapfunc(a, 'reshape', newshape, order=order)
E   File "/home/kadir/anaconda3/envs/rknn/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 56, in _wrapfunc
E     return getattr(obj, method)(*args, **kwds)
E ValueError: cannot reshape array of size 756735 into shape (256,384,3,3)
--> Load darknet model failed!


After some through searching and trials, I came to the conclusion that this error occurs when I try to convert a darknet model that has groups, group id parameters in them. Such as this from yolov4 tiny:
[route]
layers=-1
groups=2
group_id=1



What do you suggest to solve this issue?
Last time I asked help here, you guys told me that you will contact npu team about it, and I didn't hear anything else on the matter.
So please give a more solid response this me.

回复

使用道具 举报

jefferyzhang

版主

积分
12844
发表于 2020-7-24 08:35:32 | 显示全部楼层
本帖最后由 jefferyzhang 于 2020-7-24 10:01 编辑

Try the latest version of rknn-toolkit (v1.3.2 )
The yolov4 activation function 'mish' have supported after v1.3.1.
回复

使用道具 举报

brunolin

高级会员

积分
611
发表于 2020-7-24 14:04:01 | 显示全部楼层
jefferyzhang 发表于 2020-7-24 08:35
Try the latest version of rknn-toolkit (v1.3.2 )
The yolov4 activation function 'mish' have supporte ...

Hi!

Is mish op supported after 1.3.1?
You reported mish is supported from v1.3.3 in this post.
回复

使用道具 举报

rakidis

高级会员

积分
507
 楼主| 发表于 2020-7-24 14:30:14 | 显示全部楼层
Hey Jeffery,

I am not talking about yolov4, but "yolov4 tiny"

It came out in the last month, it's fairly new and fast. Also it doesn't have mish activation layer like yolov4, but it has a depthwise convolution layer like parameter to divide a tensor in half.
[route]
layers=-1
groups=2
group_id=1

Because of this group parameters I think, rknn toolkit is failing at converting the network. I couldn't find any alternative to that layer in darknet, so the problem must be solved on rknn conversion side
回复

使用道具 举报

jefferyzhang

版主

积分
12844
发表于 2020-7-24 15:14:40 | 显示全部楼层
brunolin 发表于 2020-7-24 14:04
Hi!

Is mish op supported after 1.3.1?

Sorry, I make no sense, we have to wait the version higher than 1.3.2 in these days for 'mish'.
回复

使用道具 举报

jefferyzhang

版主

积分
12844
发表于 2020-7-24 15:18:20 | 显示全部楼层
rakidis 发表于 2020-7-24 14:30
Hey Jeffery,

I am not talking about yolov4, but "yolov4 tiny"

E ValueError: cannot reshape array of size 756735 into shape (256,384,3,3)
It looks like the shape error (256*384*3*3 = 884736 != 756735),
Is any layer output with this shape?
回复

使用道具 举报

rakidis

高级会员

积分
507
 楼主| 发表于 2020-7-24 22:00:14 | 显示全部楼层
jefferyzhang 发表于 2020-7-24 15:18
E ValueError: cannot reshape array of size 756735 into shape (256,384,3,3)
It looks like the shape ...

Error looks like shape error, but it's not related to a problem with the model. When I replace route layer with a 1x1 convolution layer with appropiate number of filters to meet next layer's channel size, rknn can handle the network safely.
But this change means I cannot use pretrained weights of yolov4-tiny and I would have to train my network with imagenet to achieve weights to be used at object detection training.

Rknn toolkit simply cannot handle groups and group_id parameters from darknet framework. I observed this behaviour at darknet-resnext model also.
回复

使用道具 举报

rakidis

高级会员

积分
507
 楼主| 发表于 2020-7-28 13:39:09 | 显示全部楼层
Any developments on the topic jeffery?
回复

使用道具 举报

spmoon

注册会员

积分
152
发表于 2020-8-18 16:08:06 | 显示全部楼层
解决了吗?
回复

使用道具 举报

jefferyzhang

版主

积分
12844
发表于 2020-8-18 16:38:13 | 显示全部楼层
本帖最后由 jefferyzhang 于 2020-8-18 16:41 编辑

rknn-toolkit 1.4.0 is comming ...
You can find the preview version as below:  
    Baidu Clound: https://eyun.baidu.com/s/3eTG3VsY   (pwd:rknn)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表