Toybrick

标题: yolov4 tiny rknn conversion problem [打印本页]

作者: rakidis    时间: 2020-7-23 18:49
标题: yolov4 tiny rknn conversion problem
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    时间: 2020-7-24 08:35
本帖最后由 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    时间: 2020-7-24 14:04
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    时间: 2020-7-24 14:30
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    时间: 2020-7-24 15:14
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    时间: 2020-7-24 15:18
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    时间: 2020-7-24 22:00
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    时间: 2020-7-28 13:39
Any developments on the topic jeffery?
作者: spmoon    时间: 2020-8-18 16:08
解决了吗?
作者: jefferyzhang    时间: 2020-8-18 16:38
本帖最后由 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)





欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3