Giter VIP home page Giter VIP logo

darknet2ncnn's Introduction

darknet2ncnn

Introduction

Darknet2ncnn converts the darknet model to the ncnn model, enabling rapid deployment of the darknet network model on the mobile device.

Gitee : https://gitee.com/damone/darknet2ncnn

  1. Support network layers except local/xor conv, rnn, lstm, gru, crnn and iseg
  2. Added all activation operations not directly supported by ncnn, implemented in the layer DarknetActivation
  3. Added the implementation of the shortcut layer, implemented in the layer DarknetShortCut
  4. Added yolo layer and detection layer implementation, support YOLOV1 and YOLOV3
  5. Provides a converted model verification tool, convert_verify, which supports checking the calculation output of each layer of the network, supports convolutional layer parameter checking, and facilitates rapid positioning of problems in model conversion.

NCNN, merged darknet layers https://github.com/xiangweizeng/ncnn

Technical communication QQ group

点击链接加入群聊【darknet2ncnn】:https://jq.qq.com/?_wv=1027&k=5Gou5zw

Install&Usage

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

  2. Download source

git clone https://github.com/xiangweizeng/darknet2ncnn.git
  1. Init submodule
cd darknet2ncnn
git submodule init
git submodule update
  1. build darknet
cd darknet
make -j8
rm libdarknet.so
  1. build ncnn
# workspace darknet2ncnn
cd ncnn
mkdir build
cd build
cmake ..
make -j8
make install
cd ../../
  1. Build darknet2ncnn , convert_verify and libdarknet2ncnn.a
# workspace darknet2ncnn
make -j8
  1. Convert and verify
  • Cifar
# workspace darknet2ncnn
make 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                                          10
Loading 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.png
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                                          10
Loading weights from data/cifar.backup...Done!

Start run all operation:
conv_0 : weights diff : 0.000000
conv_0_batch_norm : slope diff : 0.000000
conv_0_batch_norm : mean diff : 0.000000
conv_0_batch_norm : variance diff : 0.000000
conv_0_batch_norm : biases diff : 0.000000
Layer: 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.071548
Layer: 15, Blob : gloabl_avg_pool_15, Total Diff 0.235242 Avg Diff: 0.023524
Layer: 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 yolo
Loading 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.jpg
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
    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 yolo
Loading weights from data/yolov3-tiny.weights...Done!

Start run all operation:
conv_0 : weights diff : 0.000000
conv_0_batch_norm : slope diff : 0.000000
conv_0_batch_norm : mean diff : 0.000000
conv_0_batch_norm : variance diff : 0.000000
conv_0_batch_norm : biases diff : 0.000000
.
.
.
conv_22 : weights diff : 0.000000
conv_22 : biases diff : 0.000000
Layer: 22, Blob : conv_22_activation, Total Diff 29411.240234 Avg Diff: 0.170619
  1. Build example
# workspace darknet2ncnn
cd example
make -j2
  1. Run classifier
# workspace example
make cifar.cifar
./classifier zoo/cifar.param  zoo/cifar.bin  data/32516_dog.png data/cifar_lable.txt
4    deer                             = 0.263103
6    frog                             = 0.224274
5    dog                              = 0.191360
3    cat                              = 0.180164
2    bird                             = 0.094251
  1. Run Yolo
  • Run YoloV3-tiny
# workspace example
 make yolov3-tiny.coco
 ./yolo zoo/yolov3-tiny.param  zoo/yolov3-tiny.bin  data/dog.jpg  data/coco.names
3  [car             ] = 0.64929 at 252.10 92.13 114.88 x 52.98
2  [bicycle         ] = 0.60786 at 111.18 134.81 201.40 x 160.01
17 [dog             ] = 0.56338 at 69.91 152.89 130.30 x 179.04
8  [truck           ] = 0.54883 at 288.70 103.80 47.98 x 34.17
3  [car             ] = 0.28332 at 274.47 100.36 48.90 x 35.03
  • YoloV3-tiny figure

NCNN:

image/

DARKNET:

image/

  1. Build benchmark
# workspace darknet2ncnn
cd benchmark
make 
  1. Run benchmark
  • Firefly RK3399 thread2
firefly@firefly:~/project/darknet2ncnn/benchmark$ ./benchdarknet 10  2 &
[1] 4556
loop_count = 10
num_threads = 2
powersave = 0
firefly@firefly:~/project/darknet2ncnn/benchmark$ taskset -pc 4,5 4556
pid 4556's current affinity list: 0-5
pid 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.49
resnext101-32x4d  min = 1219.80  max = 1232.07  avg = 1227.58
resnext152-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 = 10
num_threads = 4
powersave = 0
firefly@firefly:~/project/darknet2ncnn/benchmark$ taskset -pc 0-3 4663
pid 4663's current affinity list: 0-5
pid 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.05
resnext101-32x4d  min = 2207.74  max = 2366.66  avg = 2281.82
resnext152-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

Support network(Zoo)

Zoo(Baidu Cloud):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

Benchmark

Time: ms

Network i7-7700K 4.20GHz 8thread IMX6Q,Topeet 4thead Firefly rk3399 2thread Firefly rk3399 4thread
cifar 62 302 85 100
alexnet 92 649 218 420
darknet 28 297 88 106
darknet19 202 1218 333 433
darknet53 683 3235 897 1406
densenet201 218 2647 681 1218
extraction 244 1226 334 428
resnet18 174 764 240 338
resnet34 311 1408 402 580
resnet50 276 2092 551 925
resnet101 492 3758 952 1642
resnet152 704 5500 1363 2311
resnext50 169 2595 669 1093
resnext101-32x4d 296 5274 1227 2281
resnext152-32x4d 438 7818 1795 3282
vgg-16 884 3597 895 1300
yolov1-tiny 98 843 224 295
yolov2-tiny 155 987 252 329
yolov2 1846 Out of memofy Out of memofy Out of memofy
yolov3-tiny 159 951 245 322
yolov3 5198 Out of memofy Out of memofy Out of memofy
yolov3-spp 5702 Out of memofy Out of memofy Out of memofy

darknet2ncnn's People

Contributors

xiangweizeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

darknet2ncnn's Issues

关于安卓版本库

您好,可否将源码编译一个安卓版本的算法库啊,直接调用您例子中yolov2.cpp中的函数,方便安卓移植。我现在将相关源码放在AS中进行编译,总是会出现问题。
yolov2.cpp中的函数
CustomizedNet yolo;
register_darknet_layer(yolo);
yolo.load_param(param);
yolo.load_model(bin);

layer DarknetShortcut not exists or registered

您好,我在用ncnn加载转换后的模型时,DarknetShortcut层加载不进来:layer DarknetShortcut not exists or registered。
是要修改ncnn源码调用您自定义的darknet_shortcut.cpp进行加载吗?

自己训练的weight识别错误

可以将物体识别出来,但是类别识别错了,我替换了您项目中的weights文件和cfg文件,请问还有那里是需要修改的吗?

make error

ncnn make error when execute make -j8

In file included from /home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_arm.cpp:27:0:
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h: In function ‘void ncnn::convdw3x3s2_int8_neon(const ncnn::Mat&, ncnn::Mat&, const ncnn::Mat&, const ncnn::Option&)’:
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:679:9: error: ‘int8x8_t’ was not declared in this scope
         int8x8_t _k0 = vdup_n_s8(kernel[0]);
         ^~~~~~~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:680:18: error: expected ‘;’ before ‘_k1’
         int8x8_t _k1 = vdup_n_s8(kernel[1]);
                  ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:681:18: error: expected ‘;’ before ‘_k2’
         int8x8_t _k2 = vdup_n_s8(kernel[2]);
                  ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:682:18: error: expected ‘;’ before ‘_k3’
         int8x8_t _k3 = vdup_n_s8(kernel[3]);
                  ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:683:18: error: expected ‘;’ before ‘_k4’
         int8x8_t _k4 = vdup_n_s8(kernel[4]);
                  ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:684:18: error: expected ‘;’ before ‘_k5’
         int8x8_t _k5 = vdup_n_s8(kernel[5]);
                  ^~~
...
                           ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:753:27: error: ‘_k5’ was not declared in this scope
                       "w"(_k5),             // %15
                           ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:754:27: error: ‘_k6’ was not declared in this scope
                       "w"(_k6),             // %16
                           ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:755:27: error: ‘_k7’ was not declared in this scope
                       "w"(_k7),             // %17
                           ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:756:27: error: ‘_k8’ was not declared in this scope
                       "w"(_k8)              // %18
                           ^~~
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:653:9: warning: unused variable ‘h’ [-Wunused-variable]
     int h = bottom_blob.h;
         ^
/home/pi/workspace/darknet2ncnn/ncnn/src/layer/arm/convolutiondepthwise_3x3_int8.h:654:9: warning: unused variable ‘inch’ [-Wunused-variable]
     int inch = bottom_blob.c;
         ^~~~
src/CMakeFiles/ncnn.dir/build.make:1574: recipe for target 'src/CMakeFiles/ncnn.dir/layer/arm/convolutiondepthwise_arm.cpp.o' failed
make[2]: *** [src/CMakeFiles/ncnn.dir/layer/arm/convolutiondepthwise_arm.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/ncnn.dir/all' failed
make[1]: *** [src/CMakeFiles/ncnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

gpu问题

你好:
我尝试使用vulkan进行gpu测试,发现一直找不到gpu count,但是用官方squeezenet 在手机上运行正常,我手机是Mali G76,是我darknet那个库编译的问题吗,期待你的回复

different benchmark result

I have two models, both of them are exactly the same.
when I executed benchmark of NCNN of darknet2ncnn(exists on darknet2ncnn/ncnn/build/benchmark/) on Raspberry pi 3b, I got 150ms however with latest version of original NCNN's repository(https://github.com/Tencent/ncnn) I got 350ms.

I got hesitated. what is the problem and which one is really true?
I've built NCNN from original repository with following command :

cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_VULKAN=OFF -DNCNN_SYSTEM_GLSLANG=ON -DNCNN_BUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=../toolchains/pi3.toolchain.cmake -DPI3=ON ..
and built NCNN of darknet2ncnn with:
cmake ..

the NCNN's version of darknet2ncnn is the 2020-03-06.

How to troubleshoot problem when benchdarknet program runs slow?

I have already turned on neon option.
The benchmark is running on an imx6q devboard.

root@imx6qsabresd:/home/benchmark# ./benchdarknet
loop_count = 4
num_threads = 1
powersave = 0
gpu_device = -1
cifar min = 3984.53 max = 3986.34 avg = 3985.29
alexnet min = 6808.87 max = 6919.03 avg = 6862.98
darknet min = 2491.22 max = 2502.07 avg = 2496.54

This is benchdarknet file attributes, from readelf ouputs.
File Attributes
Tag_CPU_name: "Cortex-A9"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3
Tag_Advanced_SIMD_arch: NEONv1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_VFP_args: VFP registers
Tag_CPU_unaligned_access: v6
Tag_MPextension_use: Allowed
Tag_Virtualization_use: TrustZone

转换自己darknet模型,进行视频检测时报错:段错误 (核心已转储)

/darknet2ncnn/example$下 执行:./yolo zoo/yolov3-tiny.param zoo/yolov3-tiny.bin data/dog.jpg data/objects.names

结果如下:
10 [range hood ] = 0.35896 at -57.80 -418.17 258.84 x 1813.42
19 [shoe cabinet ] = 0.28689 at 217.76 193.62 375.95 x 304.55
10 [range hood ] = 0.31165 at -128.09 114.08 443.21 x 741.05
10 [range hood ] = 0.26759 at 5.88 -347.49 316.14 x 1676.83
10 [range hood ] = 0.25045 at -32.94 92.90 433.79 x 792.78
10 [range hood ] = 0.26288 at -60.36 -608.99 271.91 x 2195.61
10 [range hood ] = 0.28866 at -58.24 -533.50 263.50 x 2046.67
10 [range hood ] = 0.26968 at 51.96 -3.40 250.54 x 963.64
10 [range hood ] = 0.39618 at 48.71 14.22 249.38 x 938.48
段错误 (核心已转储)

而且结果完全不对,请问是什么原因?

make cifar.cifar 和 make yolov3-tiny.coco失败

你好,我在ubuntu16.04上运行readme的第10条:make cifar.cifar 时报错:make: *** No rule to make target 'cifar.cifar'. Stop. 在运行第11条时也遇到同样的问题:make: *** No rule to make target 'cifar.cifar'. Stop. 请问这是什么情况?谢谢!

是否考虑支持最新的ncnn版本呢?

我使用此版本yolo3转ncnn后,ncnn不能全部读取yolo3的层,ncnn读出来的层有50层的,但是只有13层非空,之后的都非空。所有,请教是否在考虑支持最新的nvnn版本呢?

darknet2ncnn: ./src/utils.c: 256: error: Assertion '0' failed.

Thanks to provide the source! Hope your reply!

I convert the exam pleyolov3-tiny successful, but when I convert my own yolov3 model, I recipe the message: First section must bu [net] or [network]: Success.
darknet2ncnn: ./src/utils.c: 256: error: Assertion '0' failed.
Aborted (core dumped).

Is there anyting mistake? What can I do?

how to solve it?

maxwell@maxwell#:./yolo zoo/yolov3-tiny.param zoo/yolov3-tiny.bin data/dog.jpg
data/coco.names

ModelBin read weight_data failed 0
layer load_model 33 failed
Segmentation fault (core dumped)

ncnn error :-100

When use the example ,this error occured when I use the model of the converted yolov2 , which is trained by darknet. But the yolov2-tiny model can work. Thank you for reply.

layer DarknetShortcut not exists or registered?

我训练好模型后用darknet2ncnn能成功转为bin和param,但运行检测后提示layer DarknetShortcut not exists or registered,我看在darknet2ncnn/src/register_darknet.cpp文件中有注册,请问这个有好的建议吗?

void register_darknet_layer(ncnn::Net &net)
{
  net.register_custom_layer("DarknetActivation", ncnn::DarknetActivation_layer_creator);
  net.register_custom_layer("DarknetShortcut", ncnn::DarknetShortcut_layer_creator);
  net.register_custom_layer("Yolov1Detection", ncnn::Yolov1Detection_layer_creator);
  net.register_custom_layer("Yolov3Detection", ncnn::Yolov3Detection_layer_creator);
}```

inference not work

The compile stage ran but inference not actually work .

pi@raspberrypi:~/workspace/darknet2ncnn $ 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
    1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16
    2 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  32  0.399 BFLOPs
    3 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  32
    4 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  64  0.399 BFLOPs
    5 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  64
    6 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 128  0.399 BFLOPs
    7 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 128
    8 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 256  0.399 BFLOPs
    9 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 256
   10 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   11 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 512
   12 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   13 conv    256  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 256  0.089 BFLOPs
   14 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   15 conv    255  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 255  0.044 BFLOPs
   16 yolo
   17 route  13
   18 conv    128  1 x 1 / 1    13 x  13 x 256   ->    13 x  13 x 128  0.011 BFLOPs
   19 upsample            2x    13 x  13 x 128   ->    26 x  26 x 128
   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 yolo
Loading 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.jpg
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
    1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16
    2 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  32  0.399 BFLOPs
    3 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  32
    4 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  64  0.399 BFLOPs
    5 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  64
    6 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 128  0.399 BFLOPs
    7 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 128
    8 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 256  0.399 BFLOPs
    9 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 256
   10 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   11 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 512
   12 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   13 conv    256  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 256  0.089 BFLOPs
   14 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
   15 conv    255  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 255  0.044 BFLOPs
   16 yolo
   17 route  13
   18 conv    128  1 x 1 / 1    13 x  13 x 256   ->    13 x  13 x 128  0.011 BFLOPs
   19 upsample            2x    13 x  13 x 128   ->    26 x  26 x 128
   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 yolo
Loading weights from data/yolov3-tiny.weights...Done!

Start run all operation:
conv_0 : weights diff : 0.000000
conv_0_batch_norm : slope diff : 0.000000
conv_0_batch_norm : mean diff : 0.000000
conv_0_batch_norm : variance diff : 0.000000
conv_0_batch_norm : biases diff : 0.000000
Layer: 0, Blob : conv_0_activation, Total Diff nan Avg Diff: nan
Layer: 1, Blob : maxpool_1, Total Diff nan Avg Diff: nan
conv_2 : weights diff : 0.000000
conv_2_batch_norm : slope diff : 0.000000
conv_2_batch_norm : mean diff : 0.000000
conv_2_batch_norm : variance diff : 0.000000
conv_2_batch_norm : biases diff : 0.000000
Layer: 2, Blob : conv_2_activation, Total Diff nan Avg Diff: nan
Layer: 3, Blob : maxpool_3, Total Diff nan Avg Diff: nan
conv_4 : weights diff : 0.000000
conv_4_batch_norm : slope diff : 0.000000
conv_4_batch_norm : mean diff : 0.000000
conv_4_batch_norm : variance diff : 0.000000
conv_4_batch_norm : biases diff : 0.000000
Layer: 4, Blob : conv_4_activation, Total Diff nan Avg Diff: nan
Layer: 5, Blob : maxpool_5, Total Diff nan Avg Diff: nan
conv_6 : weights diff : 0.000000
conv_6_batch_norm : slope diff : 0.000000
conv_6_batch_norm : mean diff : 0.000000
conv_6_batch_norm : variance diff : 0.000000
conv_6_batch_norm : biases diff : 0.000000
Layer: 6, Blob : conv_6_activation, Total Diff nan Avg Diff: nan
Layer: 7, Blob : maxpool_7, Total Diff nan Avg Diff: nan
conv_8 : weights diff : 0.000000
conv_8_batch_norm : slope diff : 0.000000
conv_8_batch_norm : mean diff : 0.000000
conv_8_batch_norm : variance diff : 0.000000
conv_8_batch_norm : biases diff : 0.000000
Layer: 8, Blob : conv_8_activation, Total Diff nan Avg Diff: nan
Layer: 9, Blob : maxpool_9, Total Diff nan Avg Diff: nan
conv_10 : weights diff : 0.000000
conv_10_batch_norm : slope diff : 0.000000
conv_10_batch_norm : mean diff : 0.000000
conv_10_batch_norm : variance diff : 0.000000
conv_10_batch_norm : biases diff : 0.000000
Layer: 10, Blob : conv_10_activation, Total Diff nan Avg Diff: nan
Layer: 11, Blob : maxpool_11, Total Diff nan Avg Diff: nan
conv_12 : weights diff : 0.000000
conv_12_batch_norm : slope diff : 0.000000
conv_12_batch_norm : mean diff : 0.000000
conv_12_batch_norm : variance diff : 0.000000
conv_12_batch_norm : biases diff : 0.000000
Layer: 12, Blob : conv_12_activation, Total Diff nan Avg Diff: nan
conv_13 : weights diff : 0.000000
conv_13_batch_norm : slope diff : 0.000000
conv_13_batch_norm : mean diff : 0.000000
conv_13_batch_norm : variance diff : 0.000000
conv_13_batch_norm : biases diff : 0.000000
Layer: 13, Blob : conv_13_activation, Total Diff nan Avg Diff: nan
conv_14 : weights diff : 0.000000
conv_14_batch_norm : slope diff : 0.000000
conv_14_batch_norm : mean diff : 0.000000
conv_14_batch_norm : variance diff : 0.000000
conv_14_batch_norm : biases diff : 0.000000
Layer: 14, Blob : conv_14_activation, Total Diff nan Avg Diff: nan
conv_15 : weights diff : 0.000000
conv_15 : biases diff : 0.000000
Layer: 15, Blob : conv_15_activation, Total Diff nan Avg Diff: nan
Layer: 17, Blob : route_17, Total Diff nan Avg Diff: nan
conv_18 : weights diff : 0.000000
conv_18_batch_norm : slope diff : 0.000000
conv_18_batch_norm : mean diff : 0.000000
conv_18_batch_norm : variance diff : 0.000000
conv_18_batch_norm : biases diff : 0.000000
Layer: 18, Blob : conv_18_activation, Total Diff nan Avg Diff: nan
Layer: 19, Blob : upsample_19, Total Diff nan Avg Diff: nan
Layer: 20, Blob : route_20, Total Diff nan Avg Diff: nan
conv_21 : weights diff : 0.000000
conv_21_batch_norm : slope diff : 0.000000
conv_21_batch_norm : mean diff : 0.000000
conv_21_batch_norm : variance diff : 0.000000
conv_21_batch_norm : biases diff : 0.000000
Layer: 21, Blob : conv_21_activation, Total Diff nan Avg Diff: nan
conv_22 : weights diff : 0.000000
conv_22 : biases diff : 0.000000
Layer: 22, Blob : conv_22_activation, Total Diff nan Avg Diff: nan

All the difference are 0.000 .And i tried another example like cifar.cifar

pi@raspberrypi:~/workspace/darknet2ncnn/example $ make cifar.cifar
./classifier zoo/cifar.param  zoo/cifar.bin  data/32516_dog.png data/cifar_lable.txt
3    cat                              = nan
4    deer                             = nan
1    automobile                       = nan
0    airplane                         = nan
2    bird                             = nan

Sth wrong with the weights file?

转化yolov3模型的问题

make yolov3.net
./darknet2ncnn data/yolov3.cfg data/yolov3.weights example/zoo/yolov3.param example/zoo/yolov3.bin
First section must be [net] or [network]: Success
darknet2ncnn: ./src/utils.c:256: error: Assertion `0' failed.
Makefile:58: recipe for target 'yolov3.net' failed
make: *** [yolov3.net] Aborted (core dumped)
我不知道是因为我的make命令错了还是我的模型的问题

does it have cmakelist ver?

does it have cmakelist.ver?
请问有用cmake的版本么?

想在win上进行darknet2ncnn的数据转换
但是darknet为x64, ncnn生成库为win32, 如何完成数据转换?

stack smashing in yolov3detection layer

I get the following error when loading a yolov3 model using the converter tool:

*** stack smashing detected ***: terminated

Using GDB, I get :

*** stack smashing detected ***: terminated

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff6c97801 in __GI_abort () at abort.c:79
#2 0x00007ffff6ce0897 in __libc_message (action=action@entry=do_abort,
fmt=fmt@entry=0x7ffff6e0d988 "*** %s ***: %s terminated\n")
at ../sysdeps/posix/libc_fatal.c:181
#3 0x00007ffff6d8bcd1 in __GI___fortify_fail_abort (
need_backtrace=need_backtrace@entry=false,
msg=msg@entry=0x7ffff6e0d966 "stack smashing detected")
at fortify_fail.c:33
#4 0x00007ffff6d8bc92 in __stack_chk_fail () at stack_chk_fail.c:29
#5 0x0000555555582cf4 in ncnn::Yolov3Detection::Yolov3Detection() ()
#6 0x0000000000000000 in ?? ()
(gdb) quit

加载 ncnn 模型失败

使用 Darknet 训练模型后,转化为 ncnn 模型,最后使用 ncnn 加载 .param 文件,返回 -1 ,加载失败。不知道何原因?使用caffe 训练的模型,转化后,可以加载成功。

/usr/bin/ld: skipping incompatible ncnn/build/install/lib//libncnn.a when searching for -lncnn

在ubuntu上将darknet模型成功转换为ncnn后推理成功。
现在想将ncnn模型用在arm上,
$ cd ncnn
$ mkdir -p build
$ cd build-arm-linux-gnueabi
$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/arm-linux-gnueabi.toolchain.cmake ..
$ make -j4
$ make install
交叉编译ncnn成功了

再进行libdarknet2ncnn.a生成操作,报错:
/usr/bin/ld: skipping incompatible ncnn/build/install/lib//libncnn.a when searching for -lncnn
/usr/bin/ld: cannot find -lncnn

我的ncnn/build/install/lib下是有libncnn.a的。
请问下libdarknet2ncnn交叉编译需要怎么操作?

Using darknet2ncnn with AlexeyAB/darknet

Hi @xiangweizeng,

I would like to ask for your help in using your darknet2ncnn with darknet from AlexeyAB source. I have changed the darknet/ folder with the darknet come from AlexeyAB and some line in Makefile so the source can compile.
My problem is when I using the darknet2ncnn to convert a typical network yolov3-tiny-prn: cfg, weight. darknet2ncnn run with no error. But when I used convert_verify to check the network the result showed as follow:

Start run all operation:
conv_0 : weights diff : 0.000000
conv_0_batch_norm : slope diff : 0.000000
conv_0_batch_norm : mean diff : 0.000000
conv_0_batch_norm : variance diff : 0.000000
conv_0_batch_norm : biases diff : 0.000000
Layer: 0, Blob : conv_0_activation, Total Diff 10.852427 Avg Diff: 0.000004
Layer: 1, Blob : maxpool_1, Total Diff 2.860126 Avg Diff: 0.000004
conv_2 : weights diff : 0.000000
conv_2_batch_norm : slope diff : 0.000000
conv_2_batch_norm : mean diff : 0.000000
conv_2_batch_norm : variance diff : 0.000000
conv_2_batch_norm : biases diff : 0.000000
Layer: 2, Blob : conv_2_activation, Total Diff 4.563586 Avg Diff: 0.000003
Layer: 3, Blob : maxpool_3, Total Diff 1.283248 Avg Diff: 0.000004
conv_4 : weights diff : 0.000000
conv_4_batch_norm : slope diff : 0.000000
conv_4_batch_norm : mean diff : 0.000000
conv_4_batch_norm : variance diff : 0.000000
conv_4_batch_norm : biases diff : 0.000000
Layer: 4, Blob : conv_4_activation, Total Diff 2.286713 Avg Diff: 0.000003
Layer: 5, Blob : maxpool_5, Total Diff 0.684587 Avg Diff: 0.000004
conv_6 : weights diff : 0.000000
conv_6_batch_norm : slope diff : 0.000000
conv_6_batch_norm : mean diff : 0.000000
conv_6_batch_norm : variance diff : 0.000000
conv_6_batch_norm : biases diff : 0.000000
Layer: 6, Blob : conv_6_activation, Total Diff 1.056885 Avg Diff: 0.000003
Layer: 7, Blob : maxpool_7, Total Diff 0.327580 Avg Diff: 0.000004
conv_8 : weights diff : 0.000000
conv_8_batch_norm : slope diff : 0.000000
conv_8_batch_norm : mean diff : 0.000000
conv_8_batch_norm : variance diff : 0.000000
conv_8_batch_norm : biases diff : 0.000000
Layer: 8, Blob : conv_8_activation, Total Diff 0.244931 Avg Diff: 0.000001
Layer: 9, Blob : maxpool_9, Total Diff 0.073587 Avg Diff: 0.000002
conv_10 : weights diff : 0.000000
conv_10_batch_norm : slope diff : 0.000000
conv_10_batch_norm : mean diff : 0.000000
conv_10_batch_norm : variance diff : 0.000000
conv_10_batch_norm : biases diff : 0.000000
Layer: 10, Blob : conv_10_activation, Total Diff 0.160212 Avg Diff: 0.000002
Layer: 11, Blob : maxpool_11, Total Diff 0.142812 Avg Diff: 0.000002
conv_12 : weights diff : 0.000000
conv_12_batch_norm : slope diff : 0.000000
conv_12_batch_norm : mean diff : 0.000000
conv_12_batch_norm : variance diff : 0.000000
conv_12_batch_norm : biases diff : 0.000000
Layer: 12, Blob : conv_12_activation, Total Diff 0.523872 Avg Diff: 0.000006
Layer: 13, Blob : shortcut_13_activation, Total Diff 17725.605469 Avg Diff: 0.204854
conv_14 : weights diff : 0.000000
conv_14_batch_norm : slope diff : 0.000000
conv_14_batch_norm : mean diff : 0.000000
conv_14_batch_norm : variance diff : 0.000000
conv_14_batch_norm : biases diff : 0.000000
Layer: 14, Blob : conv_14_activation, Total Diff 4164.033691 Avg Diff: 0.096247
conv_15 : weights diff : 0.000000
conv_15_batch_norm : slope diff : 0.000000
conv_15_batch_norm : mean diff : 0.000000
conv_15_batch_norm : variance diff : 0.000000
conv_15_batch_norm : biases diff : 0.000000
Layer: 15, Blob : conv_15_activation, Total Diff 24017.382812 Avg Diff: 0.555135
Layer: 16, Blob : shortcut_16_activation, Total Diff 28946.251953 Avg Diff: 0.669061
conv_17 : weights diff : 0.000000
conv_17 : biases diff : 0.000000
Layer: 17, Blob : conv_17_activation, Total Diff 296630.531250 Avg Diff: 6.883177
Layer: 19, Blob : route_19, Total Diff 24017.382812 Avg Diff: 0.555135
conv_20 : weights diff : 0.000000
conv_20_batch_norm : slope diff : 0.000000
conv_20_batch_norm : mean diff : 0.000000
conv_20_batch_norm : variance diff : 0.000000
conv_20_batch_norm : biases diff : 0.000000
Layer: 20, Blob : conv_20_activation, Total Diff 8507.630859 Avg Diff: 0.393289
Layer: 21, Blob : upsample_21, Total Diff 34030.519531 Avg Diff: 0.393289
Layer: 22, Blob : shortcut_22_activation, Total Diff 34487.667969 Avg Diff: 0.398572
conv_23 : weights diff : 0.000000
conv_23_batch_norm : slope diff : 0.000000
conv_23_batch_norm : mean diff : 0.000000
conv_23_batch_norm : variance diff : 0.000000
conv_23_batch_norm : biases diff : 0.000000
Layer: 23, Blob : conv_23_activation, Total Diff 84448.117188 Avg Diff: 0.975963
Layer: 24, Blob : shortcut_24_activation, Total Diff 92290.070312 Avg Diff: 1.066592
Layer: 25, Blob : shortcut_25_activation, Total Diff 93145.468750 Avg Diff: 1.076478
conv_26 : weights diff : 0.000000
conv_26 : biases diff : 0.000000
Layer: 26, Blob : conv_26_activation, Total Diff 1472609.375000 Avg Diff: 8.542809

As you can see Total Diff is very high and the result when running inference is very bad. I wonder what is the problem here and what I can do?

Thank you,

内存溢出,程序崩快malloc(): memory corruption,Aborted (core dumped)

我在ubuntu 16.4中安装darknet2ncnn过程中,make和install过程均没有出错,运行cifiar历程也没有问题,但是当运行yolov3-tiny历程时,出现如下:
./yolo zoo/yolov3-tiny.param zoo/yolov3-tiny.bin data/dog.jpg data/coco.names
malloc(): memory corruption
Aborted (core dumped)
请问这是什么原因,是生成的param和bin文件有问题吗?

模型文件加载的方式

你好,请问这个项目支持以下的模型加载方式吗?

1.加载二进制的 param.bin 和 bin
ncnn::Net net;
net.load_param_bin("alexnet.param.bin");
net.load_model("alexnet.bin");

2.从内存引用加载网络和模型
#include "alexnet.mem.h"
ncnn::Net net;
net.load_param(alexnet_param_bin);
net.load_model(alexnet_bin);

download error

git clone无法下载,尝试多次都是如此,请帮助我一下。

windows version

Is the ncnn supported the windows os?
I compile the ncnn,I use cmake,it appears the following error:
Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.16299.
Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
CMake Warning at tools/caffe/CMakeLists.txt:12 (message):
Protobuf not found, caffe model convert tool won't be built
Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
CMake Warning at tools/onnx/CMakeLists.txt:12 (message):
Protobuf not found, onnx model convert tool won't be built
I use the add entry,add the path,but the error is continue,please help me.

First section must be [net] or [network]:

when i run make yolov3-tiny.net ,it appears the following error,please help me.
./darknet2ncnn data/yolov3-tiny.cfg data/yolov3-tiny.weights example/zoo/yolov3-tiny.param example/zoo/yolov3-tiny.bin
First section must be [net] or [network]: Success
darknet2ncnn: ./src/utils.c:256: error: Assertion `0' failed.
Makefile:58: recipe for target 'yolov3-tiny.net' failed
make: *** [yolov3-tiny.net] Aborted (core dumped)

请问我想转自己的.cfg和.weights出错

在运行这条命令时./convert_verify data/tiny-yolo-person.cfg data/tiny-yolo-person_38000.weights example/zoo/yolov3-tiny-person.param example/zoo/yolov3-tiny-person.bin example/data/dog.jpg报错
Loading weights from data/tiny-yolo-person_38000.weights...Done!
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/wang/opencv/modules/core/src/matrix.cpp, line 538
terminate called after throwing an instance of 'cv::Exception'
what(): /home/wang/opencv/modules/core/src/matrix.cpp:538: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
已放弃 (核心已转储)

yolov3-tiny可以正常运行,但是我自己的就会出错,请问这该怎么解决

转换的文件load_param奔溃

按照你的方法,转换成功了,但是当我把 .param 和 .bin 放到android工程下去加载的时候,load_param总是无法成功加载,导致奔溃,这个是怎么回事?跟可用的param文件对比,发现生成的文件有很大的不同

result boundingbox overlap

image
你好,我这边用yolov3-tiny测试了一张图,发现person和dog以及truck的iou输出还是有所重叠。是需要进行二次IOU吗。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.