File Exchange

image thumbnail

yolov3-yolov4-matlab

version 1.2.1 (1.66 MB) by cui
Import and export Darknet™ models within MATLAB deep learning networks.

54 Downloads

Updated 30 Jun 2020

From GitHub

View Version History

View license on GitHub

Import and export Darknet models(https://github.com/pjreddie/darknet ) within MATLAB deep learning networks. The importer can import all the seriesNetworks in the darknet and some simple DAGnetworks. The exporter can export all the seriesNetworks and some of the backbone networks. In addition to importing the deep neural network, the importer can obtain the feature map size of the network, the number of parameters, and the computational power FLOPs. For yolov2, yolov3 can also import a number of previous modules for later access to the yolo layer. This program requires Matlab2020a version and above, no other dependencies.

在MATLAB深度学习网络中导入和导出Darknet模型(https://github.com/pjreddie/darknet )。importer 可以导入darknet中所有的seriesNetwork和部分简单的DAGnetwork,exporter可以导出所有的seriesNetwork和部分的backbone网络。其中importer除了导入深度神经网络外,可以获得网络的特征图大小,参数个数,计算力FLOPs。对于yolov2,yolov3也可导入前面的若干Module,以供后期接入yolo层。此程序要求Matlab2020a版本及以上,无其他任何依赖。

使用示例见main.mlx
------------------------------------------------------------------2020.6.30 update-------------------------------------------------------------------
This respository uses simplified and minimal code to reproduce the yolov3 / yolov4 detection networks and darknet classification networks. The highlights are as follows:

1、Support original version of darknet model;
2、Support training, inference, import and export of "* .cfg", "* .weights" models;
3、Support the latest yolov3, yolov4 models;
4、Support darknet classification model;
5、Support all kinds of indicators such as feature map size calculation, flops calculation and so on.
These code is highly readable and more brief than other frameworks such as pytorch and tensorflow!
但是不包含各种训练数据增强tricks
---------------------------------------------------------------------------------------------------------------------------------------------
all models downloads link:
链接:https://pan.baidu.com/s/1UvPKSlT7K3hzeXof4ovN_A
提取码:dbbo

Cite As

cui (2021). yolov3-yolov4-matlab (https://github.com/cuixing158/yolov3-yolov4-matlab), GitHub. Retrieved .

Comments and Ratings (10)

Hind Haboubi

i'm getting this error, how can i solve it please:
Error using importDarkNetLayers (line 38)
Cannot open file: ./cfg/yolov3-tiny.cfg

Error in importDarknetWeights (line 30)
moduleTypeList,moduleInfoList,layerToModuleIndex] = importDarkNetLayers(cfgfile);% only weights需要cutoff,layer都导入

Error in newyolo (line 19)
[lgModel,hyperParams] = importDarknetWeights(cfg_file,weight_file);

cui

hi,all
Single-frame GPU time-consuming performance evaluation:
benchmarks: Inter(R) Core(TM) i7-6700 CPU@3.4GHz, GTX1070-8G, win10
yolov4 yolov3 yolov4-tiny yolov3-tiny yolov3-tiny-prn
Matlab2020a 0.4秒 0.2秒 0.07秒 0.06秒 0.06秒
Matlab2021a 0.3秒 0.18秒 0.07秒 0.06秒 0.06秒

jt zhang

Liu Fred

cui

hi, cosku oksuz:
Can you ensure that the cfg and weights files correspond to each other? If there is a problem with the consistency, you can share your model file.

cosku oksuz

I am getting an following error when using the new version.

Error using importDarknetWeights (line 82)
方差应该大于0!

cui

2020.7.1 new vision, support yolov4-tiny and yolov3-tiny-prn

lingyun gou

非常棒,如果出现输入参数不足的报错请参考https://github.com/cuixing158/yolov3-yolov4-matlab/issues/9

Abdullah

I am getting error, can you help?

cfg_file = 'model/darknet19.cfg';
weight_file = 'model/darknet19.weights';
[mynet,hyperParams,numsNetParams,FLOPs] = importDarknetNetwork(cfg_file,weight_file);

This module No: 2 [convolutional],have #params:1024 ,FLops:67108864 ,feature map size:(256*256)
This module No: 4 [convolutional],have #params:18752 ,FLops:307232768 ,feature map size:(128*128)
This module No: 6 [convolutional],have #params:74368 ,FLops:304611328 ,feature map size:( 64* 64)
This module No: 7 [convolutional],have #params:8512 ,FLops:34865152 ,feature map size:( 64* 64)
This module No: 8 [convolutional],have #params:74368 ,FLops:304611328 ,feature map size:( 64* 64)
This module No:10 [convolutional],have #params:296192 ,FLops:303300608 ,feature map size:( 32* 32)
This module No:11 [convolutional],have #params:33408 ,FLops:34209792 ,feature map size:( 32* 32)
This module No:12 [convolutional],have #params:296192 ,FLops:303300608 ,feature map size:( 32* 32)
This module No:14 [convolutional],have #params:1182208 ,FLops:302645248 ,feature map size:( 16* 16)
This module No:15 [convolutional],have #params:132352 ,FLops:33882112 ,feature map size:( 16* 16)
This module No:16 [convolutional],have #params:1182208 ,FLops:302645248 ,feature map size:( 16* 16)
This module No:17 [convolutional],have #params:132352 ,FLops:33882112 ,feature map size:( 16* 16)
This module No:18 [convolutional],have #params:1182208 ,FLops:302645248 ,feature map size:( 16* 16)
This module No:20 [convolutional],have #params:4723712 ,FLops:302317568 ,feature map size:( 8* 8)
This module No:21 [convolutional],have #params:526848 ,FLops:33718272 ,feature map size:( 8* 8)
This module No:22 [convolutional],have #params:4723712 ,FLops:302317568 ,feature map size:( 8* 8)
This module No:23 [convolutional],have #params:526848 ,FLops:33718272 ,feature map size:( 8* 8)
This module No:24 [convolutional],have #params:4723712 ,FLops:302317568 ,feature map size:( 8* 8)
This module No:25 [convolutional],have #params:1025000 ,FLops:65600000 ,feature map size:( 8* 8)
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in importDarknetNetwork (line 28)
header = fread(fid_w, 3, '*int32');

MATLAB Release Compatibility
Created with R2020a
Compatible with R2020a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!