1. 程式人生 > >配置YOLO2(ubuntu16.04+cuda8.0+opencv3.1.0)

配置YOLO2(ubuntu16.04+cuda8.0+opencv3.1.0)

href seconds make fun put ges jre 成功 下載

要求已經安裝好了CUDA 8.0 以及OpenCV3.1.0

YOLO官方網站

配置darknet

git clone https://github.com/pjreddie/darknet  
cd darknet  
make  

如果沒有報錯輸入

./darknet  

得到輸出

./darknet <function>  

說明darknet配置成功

打開Makefile文件,將開頭幾行改為

GPU=1
CUDNN=1
OPENCV=1

接著查詢自己GPU的計算能力,查看Makefile是否包含,如下我的GPU計算能力為6.1,調整後為:

ARCH= -gencode arch=compute_30,code=sm_30       -gencode arch=compute_35,code=sm_35       -gencode arch=compute_50,code=[sm_50,compute_50]       -gencode arch=compute_61,code=[sm_61,compute_61]       -gencode arch=compute_52,code=[sm_52,compute_52]

之後重新編譯,就可以實現基於cuda和opencv的編譯

下載預訓練文件

wget https://
pjreddie.com/media/files/yolo.weights

測試

./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg  

我得到的結果是:

layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   608 x 608 x   3   ->   608 x 608 x  32
    1 max          2 x 2 / 2   608 x 608 x  32   ->   304
x 304 x 32 2 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3 max 2 x 2 / 2 304 x 304 x 64 -> 152 x 152 x 64 4 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 5 conv 64 1 x 1 / 1 152 x 152 x 128 -> 152 x 152 x 64 6 conv 128 3 x 3 / 1 152 x 152 x 64 -> 152 x 152 x 128 7 max 2 x 2 / 2 152 x 152 x 128 -> 76 x 76 x 128 8 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 9 conv 128 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 128 10 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 11 max 2 x 2 / 2 76 x 76 x 256 -> 38 x 38 x 256 12 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 13 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 14 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 15 conv 256 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 256 16 conv 512 3 x 3 / 1 38 x 38 x 256 -> 38 x 38 x 512 17 max 2 x 2 / 2 38 x 38 x 512 -> 19 x 19 x 512 18 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 19 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 20 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 21 conv 512 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 512 22 conv 1024 3 x 3 / 1 19 x 19 x 512 -> 19 x 19 x1024 23 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 24 conv 1024 3 x 3 / 1 19 x 19 x1024 -> 19 x 19 x1024 25 route 16 26 conv 64 1 x 1 / 1 38 x 38 x 512 -> 38 x 38 x 64 27 reorg / 2 38 x 38 x 64 -> 19 x 19 x 256 28 route 27 24 29 conv 1024 3 x 3 / 1 19 x 19 x1280 -> 19 x 19 x1024 30 conv 425 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 425 31 detection mask_scale: Using default 1.000000 Loading weights from yolo.weights...Done! data/dog.jpg: Predicted in 0.070790 seconds. dog: 82% car: 26% truck: 65% bicycle: 85% init done opengl support available

技術分享圖片

配置YOLO2(ubuntu16.04+cuda8.0+opencv3.1.0)