Yolo-Darknet的安装和使用

1. Yolo-Darknet介绍

YOLO是基于深度学习方法的端到端实时目标检测系统,目前有三个版本,Yolo-v1,Yolo-9000,Yolo-v2。Darknet是Yolo的实现,但Darknet不仅包含Yolo的实现,还包括其它内容。

2. Darknet安装

安装过程如下:

# 代码下载
git clone https://github.com/pjreddie/darknet.git
 
# 修改Makefile
cd darknet
sed -i '1s/GPU=0/GPU=1/' Makefile
sed -i '2s/CUDNN=0/CUDNN=1/' Makefile
sed -i '3s/OPENCV=0/OPENCV=1/' Makefile
 
# 安装
make
 
# 下载预训练的模型
wget https://pjreddie.com/media/files/yolo.weights
wget https://pjreddie.com/media/files/tiny-yolo-voc.weights
wget http://pjreddie.com/media/files/yolov1.weights
wget http://pjreddie.com/media/files/tiny-yolo.weights
wget http://pjreddie.com/media/files/tiny-coco.weights
wget http://pjreddie.com/media/files/yolo-coco.weights

3. Yolo-v2用法

  • 使用预训练的模型进行目标检测
./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg

Result

  • 输入图像名称进行检测
$ ./darknet detect cfg/yolo.cfg yolo.weights
# 输入 data/horses.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!
Enter Image Path: data/horses.jpg
data/horses.jpg: Predicted in 0.030211 seconds.
horse: 46%
horse: 59%
horse: 91%
 
(predictions:31): Gtk-WARNING **: cannot open display:

result

  • 设置检测阈值
$ ./darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg -thresh 0.1

result

  • 检测视频
$ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights <video file>

参考资料

  1. https://pjreddie.com/darknet/install/

  2. https://pjreddie.com/darknet/yolo/

  3. https://pjreddie.com/darknet/yolov1/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值