VIM3 NPU - yolov4-tiny import model issue

Dear Khadas Team,

I use “aml_npu_sdk_6.4.0.10” to transform yolo model. When using “0_import_model.sh” to import yolo4-tiny model, the following error message appears.

Please help me to solve the issue. Thanks a lot.

~/aml_npu_sdk_6.4.0.10/acuity-toolkit/conversion_scripts$ ./0_import_model.sh

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:

/home/allanwang/aml_npu_sdk_6.4.0.10/acuity-toolkit/bin/acuitylib/onnx_tf/common/init.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release… Use node.outputs instead.
warnings.warn(message)
I Start importing darknet…
I Convert -1 net
I Convert 0 convolutional
I Convert 1 convolutional
I Convert 2 convolutional
I Convert 3 route
I Convert 4 convolutional
I Convert 5 convolutional
I Convert 6 route
I Convert 7 convolutional
I Convert 8 route
I Convert 9 maxpool
I Convert 10 convolutional
I Convert 11 route
I Convert 12 convolutional
I Convert 13 convolutional
I Convert 14 route
I Convert 15 convolutional
I Convert 16 route
I Convert 17 maxpool
I Convert 18 convolutional
I Convert 19 route
I Convert 20 convolutional
I Convert 21 convolutional
I Convert 22 route
I Convert 23 convolutional
I Convert 24 route
I Convert 25 maxpool
I Convert 26 convolutional
I Convert 27 convolutional
I Convert 28 convolutional
I Convert 29 convolutional
I Convert 30 yolo
I Convert 31 route
I Convert 32 convolutional
I Convert 33 upsample
I Convert 34 route
I Convert 35 convolutional
Traceback (most recent call last):
File “convertdarknet.py”, line 34, in
File “convertdarknet.py”, line 27, in main
File “acuitylib/vsi_nn.py”, line 130, in load_darknet
File “acuitylib/converter/convert_darknet.py”, line 517, in converte
File “acuitylib/converter/convert_darknet.py”, line 583, in build_graph
File “acuitylib/converter/convert_darknet.py”, line 418, in assign
File “numpy/core/fromnumeric.py”, line 292, in reshape
File “numpy/core/fromnumeric.py”, line 56, in _wrapfunc
ValueError: cannot reshape array of size 756735 into shape (256,384,3,3)
[4079] Failed to execute script convertdarknet

(Download yolov4-tiny.cfg & yolov4-tiny.weights to test)

https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4-tiny.cfg

https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights

@allanwang YOLO-V4 Is already on our plan list, We will complete this in future plans, but it will take some time to adapt before use or conversion. It is still unclear where the problem is

我目前使用 yolov4模型转换,可以完成模型转换和代码生成,但是预测的结果完全是混乱的,不是精度层面的问题,模型在PC上面测试是没有问题的,请问有什么解决方案吗? 模型与YoloV3相比就是多增加了一些会快捷连接。 我使用的cfg:yolov4-pacsp-s.cfg

@Frank 期待收到你的回复 ,或者是给说明下目前可能存在的原因。

@liushuan 你是怎么把yolo_v4替换进我们demo的,C端的代码你是重构了么

@Frank 我的yolov4 网络 的 head 与 yolov3一样,所以后处理用的是yolov3的流程呢, 目前我的yolov4 就是中间加了些shortcut 即csp这种结构,其他都是一样的。

我的 cfg 文件就是这个代码路径 https://github.com/Tianxiaomo/pytorch-YOLOv4 cfg里面的 yolov4-pacsp-s.cfg

@allanwang yolov4的后处理和yolov3在处理上还是有一些区别的,直接套用yolov3的应该是行不通的.最起码很多参数是需要调整的

我的训练代码,后处理都是用的 yolov3的,只是把之前的 yolov3.cfg 换成了 yolov4-pacsp-s.cfg 其他没有任何改变噢。

@Frank 你可以看下这个cfg 文件,与其说是yolov4, 我这个只是用了yolov4 的backbone 其它我都是走的yolov3的代码流程。

@liushuan 那参数也是需要调整的.yolov4我们有支持的计划,你可以等待一下

@Frank 参数调整你是值哪一块儿呢?我这边能不能自己调整呢?

@liushuan aml_npu_app/detect_library/model_code/detect_yolo_v3 这个目录下的源码

嗯嗯,多谢,我已经找到原因了,就是需要改动 yolov3_process.c这个代码