Series
- Part 1: compile darknet on ubuntu 16.04
- Part 2: compile darknet on windows 10
- Part 3: compile caffe-yolov3 on ubuntu 16.04
Guide
Darknet is an open source neural network framework written in C
and CUDA
. It is fast, easy to install, and supports CPU and GPU computation.
optional dependencies:
- opencv
- gpu (CUDA/CUDNN)
repo intro
see darknet
This repository supports:
- both Windows(VS 2015 (v140)) and Linux (GCC>=4.9)
- CPU and GPU (with CC >= 3.0)
- both OpenCV 2.x.x and OpenCV <= 3.4.0 (3.4.1 and higher isn’t supported)
- both cuDNN v5-v7
- CUDA >= 7.5
- also create SO-library on Linux and DLL-library on Windows
compile
my system requirements (same as caffe on ubuntu 16.04)
- ubuntu 16.04
- GeForce 1060 (6G)
- cuda: 9.2
- cudnn: 7.1.4
- opencv: 3.3.0
- openmp
commands
1 | git clone https://github.com/AlexeyAB/darknet.git |
options:
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=0
AVX=0
OPENMP=1
LIBSO=1
now compile with
1 | make -j8 |
OK. now we have darknet
, darknet.so
and uselib
which use darknet.so
fix error
CUDNN error:
Try to load cfg: ./ped.cfg, weights: ./ped.weights, clear = 0
layer filters size/strd(dil) input output
0
cuDNN status Error in: file: ./src/convolutional_layer.c : () : line: 301 : build time: Sep 24 2019 - 10:28:26
cuDNN Error: CUDNN_STATUS_BAD_PARAM
fix
Makefile options:
CUDNN=0
and compile again
1 | make -j8 |
see here
pretrained models
dataset
- coco: 80 classes
- voc: 20 classes
model
yolov3: 0-106 layers
yolov2: 0-31 layers
yolov3.cfg (236 MB COCO Yolo v3) - requires 4 GB GPU-RAM: yolov3.weights
yolov2.cfg (194 MB COCO Yolo v2) - requires 4 GB GPU-RAM: yolov2.weights
demo
yolov2
1 | sh ./image_yolov2.sh |
or
1 | ./darknet detector test ./cfg/coco.data ./cfg/yolov2.cfg ./yolov2.weights data/dog.jpg -i 0 -thresh 0.2 |
output
29 conv 1024 3 x 3 / 1 13 x 13 x1280 -> 13 x 13 x1024 3.987 BF
30 conv 425 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 425 0.147 BF
31 detection
mask_scale: Using default '1.000000'
Total BFLOPS 29.475
Loading weights from ./yolov2.weights...
seen 32
Done!
data/dog.jpg: Predicted in 0.000000 milli-seconds.
dog: 79%
bicycle: 84%
truck: 77%
Not compiled with OpenCV, saving to predictions.png instead
view results
1 | eog prediction.png |
yolov3
1 | sh ./image_yolov3.sh |
or
1 | ./darknet detector test ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights data/dog.jpg -i 0 -thresh 0.25 |
output
104 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 1.595 BF
105 conv 255 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 255 0.353 BF
106 yolo
Total BFLOPS 65.864
Loading weights from ./yolov3.weights...
seen 64
Done!
data/dog.jpg: Predicted in 0.000000 milli-seconds.
bicycle: 99%
dog: 100%
truck: 93%
Not compiled with OpenCV, saving to predictions.png instead
view results
1 | eog prediction.png |
uselib
1 | ./uselib data/dog.jpg |
output
100 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 1.595 BF
101 conv 128 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 128 0.177 BF
102 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 1.595 BF
103 conv 128 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 128 0.177 BF
104 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 1.595 BF
105 conv 255 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 255 0.353 BF
106 yolo
Total BFLOPS 65.864
Loading weights from yolov3.weights...
seen 64
Done!
object names loaded
input image or video filename: dog - obj_id = 16, x = 123, y = 223, w = 196, h = 319, prob = 0.998
truck - obj_id = 7, x = 474, y = 87, w = 216, h = 78, prob = 0.931
bicycle - obj_id = 1, x = 117, y = 124, w = 451, h = 308, prob = 0.99
darknet.py
1 | python darknet.py |
Reference
History
- 20181031: created.