• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README.mdH A D21-May-20212 KiB6644

darknet2ncnn.cppH A D21-May-202131.1 KiB926801

README.md

1# Darknet To NCNN Conversion Tools
2
3This is a standalone darknet2ncnn converter without additional dependency.
4
5Support yolov4, yolov4-tiny, yolov3, yolov3-tiny and enet-coco.cfg (EfficientNetB0-Yolov3).
6
7Another conversion tool based on darknet can be found at: [darknet2ncnn](https://github.com/xiangweizeng/darknet2ncnn)
8
9## Usage
10
11```
12Usage: darknet2ncnn [darknetcfg] [darknetweights] [ncnnparam] [ncnnbin] [merge_output]
13        [darknetcfg]     .cfg file of input darknet model.
14        [darknetweights] .weights file of input darknet model.
15        [cnnparam]       .param file of output ncnn model.
16        [ncnnbin]        .bin file of output ncnn model.
17        [merge_output]   merge all output yolo layers into one, enabled by default.
18```
19
20## Example
21
22### 1. Convert yolov4-tiny cfg and weights
23
24Download pre-trained [yolov4-tiny.cfg](https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4-tiny.cfg) and [yolov4-tiny.weights](https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights) or with your own trained weight.
25
26Convert cfg and weights:
27```
28./darknet2ncnn yolov4-tiny.cfg yolov4-tiny.weights yolov4-tiny.param yolov4-tiny.bin 1
29```
30
31If succeeded, the output would be:
32```
33Loading cfg...
34WARNING: The ignore_thresh=0.700000 of yolo0 is too high. An alternative value 0.25 is written instead.
35WARNING: The ignore_thresh=0.700000 of yolo1 is too high. An alternative value 0.25 is written instead.
36Loading weights...
37Converting model...
3883 layers, 91 blobs generated.
39NOTE: The input of darknet uses: mean_vals=0 and norm_vals=1/255.f.
40NOTE: Remeber to use ncnnoptimize for better performance.
41```
42
43### 2. Optimize graphic
44
45```
46./ncnnoptimize yolov4-tiny.param yolov4-tiny.bin yolov4-tiny-opt.param yolov4-tiny-opt.bin 0
47```
48
49### 3. Test
50
51build examples/yolov4.cpp and test with:
52
53```
54./yolov4 dog.jpg
55```
56
57The result will be:
58
59![](https://github.com/Tencent/ncnn/blob/master/tools/darknet/output.jpg)
60
61
62## How to run with benchncnn
63
64Set 2=0.3 for Yolov3DetectionOutput layer.
65
66