• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

darknet2ncnn: darknet2ncnn将darknet 模型转换为ncnn模型,实现darknet网络模型在移 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

darknet2ncnn

开源软件地址:

https://gitee.com/damone/darknet2ncnn

开源软件介绍:

darknet2ncnn

简介

darknet2ncnn将darknet 模型转换为ncnn模型,实现darknet网络模型在移动端的快速部署

码云 : https://gitee.com/damone/darknet2ncnn

  1. 除 local/xor conv, rnn, lstm, gru, crnn及iseg外,均提供支持
  2. 自定义添加了所有ncnn不直接支持的activation操作,实现位于层DarknetActivation
  3. 自定义添加了shortcut层的实现,实现位于层DarknetShortCut
  4. 自定义添加了yolo层及detection层的实现,支持YOLOV1及YOLOV3
  5. 提供了转换后的模型校验工具,convert_verify,支持检验每一层网络的计算输出,支持卷积层参数检查,方便快速定位模型转换中出现的问题

安装及使用

  1. Install opencv-dev, gcc, g++, make, cmake

  2. 下载源码

git clone https://github.com/xiangweizeng/darknet2ncnn.git
  1. 初始化 submodule
cd darknet2ncnngit submodule initgit submodule update
  1. 构建 darknet
cd darknet2make -j8rm libdarknet.so
  1. 构建 ncnn
# workspace darknet2ncnncd ncnnmkdir buildcd buildcmake ..make -j8make installcd ../../
  1. 构建 darknet2ncnn , convert_verify and libdarknet2ncnn.a
# workspace darknet2ncnnmake -j8
  1. 模型转换及验证
  • Cifar
# workspace darknet2ncnnmake cifar./darknet2ncnn data/cifar.cfg  data/cifar.backup example/zoo/cifar.param  example/zoo/cifar.bin layer     filters    size              input                output    0 conv    128  3 x 3 / 1    28 x  28 x   3   ->    28 x  28 x 128  0.005 BFLOPs    1 conv    128  3 x 3 / 1    28 x  28 x 128   ->    28 x  28 x 128  0.231 BFLOPs...   13 dropout       p = 0.50               25088  ->  25088   14 conv     10  1 x 1 / 1     7 x   7 x 512   ->     7 x   7 x  10  0.001 BFLOPs   15 avg                        7 x   7 x  10   ->    10   16 softmax                                          10Loading weights from data/cifar.backup...Done!./convert_verify data/cifar.cfg  data/cifar.backup example/zoo/cifar.param  example/zoo/cifar.bin  example/data/21263_ship.pnglayer     filters    size              input                output    0 conv    128  3 x 3 / 1    28 x  28 x   3   ->    28 x  28 x 128  0.005 BFLOPs    1 conv    128  3 x 3 / 1    28 x  28 x 128   ->    28 x  28 x 128  0.231 BFLOPs...   13 dropout       p = 0.50               25088  ->  25088   14 conv     10  1 x 1 / 1     7 x   7 x 512   ->     7 x   7 x  10  0.001 BFLOPs   15 avg                        7 x   7 x  10   ->    10   16 softmax                                          10Loading weights from data/cifar.backup...Done!Start run all operation:conv_0 : weights diff : 0.000000conv_0_batch_norm : slope diff : 0.000000conv_0_batch_norm : mean diff : 0.000000conv_0_batch_norm : variance diff : 0.000000conv_0_batch_norm : biases diff : 0.000000Layer: 0, Blob : conv_0_activation, Total Diff 595.703918 Avg Diff: 0.005936...Layer: 14, Blob : conv_14_activation, Total Diff 35.058342 Avg Diff: 0.071548Layer: 15, Blob : gloabl_avg_pool_15, Total Diff 0.235242 Avg Diff: 0.023524Layer: 16, Blob : softmax_16, Total Diff 0.000001 Avg Diff: 0.000000
  • Yolov3-tiny
 make yolov3-tiny.net ./darknet2ncnn data/yolov3-tiny.cfg  data/yolov3-tiny.weights example/zoo/yolov3-tiny.param  example/zoo/yolov3-tiny.bin layer     filters    size              input                output    0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  16  0.150 BFLOPs...   22 conv    255  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 255  0.088 BFLOPs   23 yoloLoading weights from data/yolov3-tiny.weights...Done!./convert_verify data/yolov3-tiny.cfg  data/yolov3-tiny.weights example/zoo/yolov3-tiny.param  example/zoo/yolov3-tiny.bin example/data/dog.jpglayer     filters    size              input                output    0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  16  0.150 BFLOPs    1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16...   20 route  19 8   21 conv    256  3 x 3 / 1    26 x  26 x 384   ->    26 x  26 x 256  1.196 BFLOPs   22 conv    255  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 255  0.088 BFLOPs   23 yoloLoading weights from data/yolov3-tiny.weights...Done!Start run all operation:conv_0 : weights diff : 0.000000conv_0_batch_norm : slope diff : 0.000000conv_0_batch_norm : mean diff : 0.000000conv_0_batch_norm : variance diff : 0.000000conv_0_batch_norm : biases diff : 0.000000...conv_22 : weights diff : 0.000000conv_22 : biases diff : 0.000000Layer: 22, Blob : conv_22_activation, Total Diff 29411.240234 Avg Diff: 0.170619
  1. 构建 example
# workspace darknet2ncnncd examplemake -j2
  1. 运行 classifier
# workspace examplemake cifar.cifar./classifier zoo/cifar.param  zoo/cifar.bin  data/32516_dog.png data/cifar_lable.txt4    deer                             = 0.2631036    frog                             = 0.2242745    dog                              = 0.1913603    cat                              = 0.1801642    bird                             = 0.094251
  1. 运行 Yolo
  • Run YoloV3-tiny
# workspace example make yolov3-tiny.coco ./yolo zoo/yolov3-tiny.param  zoo/yolov3-tiny.bin  data/dog.jpg  data/coco.names3  [car             ] = 0.64929 at 252.10 92.13 114.88 x 52.982  [bicycle         ] = 0.60786 at 111.18 134.81 201.40 x 160.0117 [dog             ] = 0.56338 at 69.91 152.89 130.30 x 179.048  [truck           ] = 0.54883 at 288.70 103.80 47.98 x 34.173  [car             ] = 0.28332 at 274.47 100.36 48.90 x 35.03
  • YoloV3-tiny figure

NCNN:

image/

DARKNET:

image/

  1. 构建 benchmark
# workspace darknet2ncnncd benchmarkmake 
  1. 运行 benchmark
  • Firefly RK3399 thread2
firefly@firefly:~/project/darknet2ncnn/benchmark$ ./benchdarknet 10  2 &[1] 4556loop_count = 10num_threads = 2powersave = 0firefly@firefly:~/project/darknet2ncnn/benchmark$ taskset -pc 4,5 4556pid 4556's current affinity list: 0-5pid 4556's new affinity list: 4,5                    cifar  min =   85.09  max =   89.15  avg =   85.81         alexnet  min =  218.38  max =  220.96  avg =  218.88         darknet  min =   88.38  max =   88.95  avg =   88.63       darknet19  min =  330.55  max =  337.12  avg =  333.64       darknet53  min =  874.69  max =  920.99  avg =  897.19     densenet201  min =  678.99  max =  684.97  avg =  681.38      extraction  min =  332.78  max =  340.54  avg =  334.98        resnet18  min =  238.93  max =  245.66  avg =  240.32        resnet34  min =  398.92  max =  404.93  avg =  402.18        resnet50  min =  545.39  max =  558.67  avg =  551.90       resnet101  min =  948.88  max =  960.51  avg =  952.99       resnet152  min = 1350.78  max = 1373.51  avg = 1363.40       resnext50  min =  660.55  max =  698.07  avg =  669.49resnext101-32x4d  min = 1219.80  max = 1232.07  avg = 1227.58resnext152-32x4d  min = 1788.03  max = 1798.79  avg = 1795.48          vgg-16  min =  883.33  max =  903.98  avg =  895.03     yolov1-tiny  min =  222.40  max =  227.51  avg =  224.67     yolov2-tiny  min =  250.54  max =  259.84  avg =  252.38     yolov3-tiny  min =  240.80  max =  249.98  avg =  245.08
  • Firefly RK3399 thread4
firefly@firefly:~/project/darknet2ncnn/benchmark$ ./benchdarknet 10  4 &[1] 4663 loop_count = 10num_threads = 4powersave = 0firefly@firefly:~/project/darknet2ncnn/benchmark$ taskset -pc 0-3 4663pid 4663's current affinity list: 0-5pid 4663's new affinity list: 0-3                   cifar  min =   96.51  max =  108.22  avg =  100.60         alexnet  min =  411.38  max =  432.00  avg =  420.11         darknet  min =  101.89  max =  119.73  avg =  106.46       darknet19  min =  421.46  max =  453.59  avg =  433.74       darknet53  min = 1375.30  max = 1492.79  avg = 1406.82     densenet201  min = 1154.26  max = 1343.53  avg = 1218.28      extraction  min =  399.31  max =  460.01  avg =  428.17        resnet18  min =  317.70  max =  376.89  avg =  338.93        resnet34  min =  567.30  max =  604.44  avg =  580.65        resnet50  min =  838.94  max =  978.21  avg =  925.14       resnet101  min = 1562.60  max = 1736.91  avg = 1642.27       resnet152  min = 2250.32  max = 2394.38  avg = 2311.42       resnext50  min =  993.34  max = 1210.04  avg = 1093.05resnext101-32x4d  min = 2207.74  max = 2366.66  avg = 2281.82resnext152-32x4d  min = 3139.89  max = 3372.58  avg = 3282.99          vgg-16  min = 1259.17  max = 1359.55  avg = 1300.04     yolov1-tiny  min =  272.31  max =  330.71  avg =  295.98     yolov2-tiny  min =  314.25  max =  352.12  avg =  329.02     yolov3-tiny  min =  300.28  max =  349.13  avg =  322.54

支持的网络模型(Zoo)

Zoo(百度云)::https://pan.baidu.com/s/1BgqL8p1yB4gRPrxAK73omw

Cifar

  1. cifar

ImageNet

  1. alexnet
  2. darknet
  3. darknet19
  4. darknet53
  5. densenet201
  6. extraction
  7. resnet18
  8. resnet34
  9. resnet50
  10. resnet101
  11. resnet152
  12. resnext50
  13. resnext101-32x4d
  14. resnext152-32x4d
  15. vgg-16

YOLO

  1. yolov1-tiny
  2. yolov2-tiny
  3. yolov2
  4. yolov3-tiny
  5. yolov3
  6. yolov3-spp

性能评估

时间单位: ms

Networki7-7700K 4.20GHz 8threadIMX6Q,Topeet 4theadFirefly rk3399 2threadFirefly rk3399 4thread
cifar6230285100
alexnet92649218420
darknet2829788106
darknet192021218333433
darknet5368332358971406
densenet20121826476811218
extraction2441226334428
resnet18174764240338
resnet343111408402580
resnet502762092551925
resnet10149237589521642
resnet152704550013632311
resnext5016925956691093
resnext101-32x4d296527412272281
resnext152-32x4d438781817953282
vgg-1688435978951300
yolov1-tiny98843224295
yolov2-tiny155987252329
yolov21846Out of memofyOut of memofyOut of memofy
yolov3-tiny159951245322
yolov35198Out of memofyOut of memofyOut of memofy
yolov3-spp5702Out of memofyOut of memofyOut of memofy

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap