darknet - Tiny YOLOv3 test and training (测试 and 训练)

darknet - Tiny YOLOv3 test and training (测试 and 训练)

https://pjreddie.com/darknet/yolo/
https://github.com/AlexeyAB/darknet

1. Tiny YOLOv3 - test

We have a very small model as well for constrained environments, yolov3-tiny. To use this model, first download the weights:

constrain [kənˈstreɪn]:vt. 驱使,强迫,束缚
wget https://pjreddie.com/media/files/yolov3-tiny.weights

Then run the detector with the tiny config file and weights:

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg
strong@foreverstrong:~$ ssh yongqiang@192.168.*.***
yongqiang@192.168.*.***'s password: 
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.13.0-36-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

20 packages can be updated.
11 updates are security updates.

Last login: Thu Oct 18 20:11:29 2018 from 192.168.1.124
yongqiang@server-sys:~$ 
yongqiang@server-sys:~$ cd darknet_work/darknet_181018/darknet/
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ 
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ make clean

yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ 
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ make

yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ 
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ wget https://pjreddie.com/media/files/yolov3-tiny.weights

yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ cat ./cfg/yolov3-tiny.cfg 
[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=2
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
./darknet detect ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights ./data/dog.jpg
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ ./darknet detect ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights ./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 ./yolov3-tiny.weights...Done!
./data/dog.jpg: Predicted in 0.003906 seconds.
dog: 57%
car: 52%
truck: 56%
car: 62%
bicycle: 59%
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$

2. Tiny YOLOv3 - training

2.1 How to train yolov3-tiny (to detect your custom objects):

darknet.exe partial cfg/yolov3-tiny.cfg yolov3-tiny.weights yolov3-tiny.conv.15 15

./darknet partial ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights ./yolov3-tiny.conv.15 15
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$ ./darknet partial ./cfg/yolov3-tiny.cfg ./yolov3-tiny.weights ./yolov3-tiny.conv.15 15
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 ./yolov3-tiny.weights...Done!
Saving weights to ./yolov3-tiny.conv.15
yongqiang@server-sys:~/darknet_work/darknet_181018/darknet$
  • Make your custom model yolov3-tiny-obj.cfg based on cfg/yolov3-tiny_obj.cfg instead of yolov3.cfg
  • Start training:
darknet.exe detector train data/obj.data yolov3-tiny-obj.cfg yolov3-tiny.conv.15
./darknet detector train ./train_cfg/yolov3_tiny_101.data ./train_cfg/yolov3_tiny_101.cfg ./yolov3-tiny.conv.15 -gpus 0,1,2,3 2> yolov3_tiny_101_stderr_v0.txt | tee yolov3_tiny_101_stdout_v0.txt

For training Yolo based on other models (DenseNet201-Yolo or ResNet50-Yolo), you can download and get pre-trained weights as showed in this file: https://github.com/AlexeyAB/darknet/blob/master/build/darknet/x64/partial.cmd If you made you custom model that isn’t based on other models, then you can train it without pre-trained weights, then will be used random initial weights.
要基于其他模型 (DenseNet201-Yolo or ResNet50-Yolo) 训练 Yolo,您可以下载并获取此文件中所示的预训练权重:https://github.com/AlexeyAB/darknet/blob/master/build/darknet/x64/partial.cmd 如果您创建的定制模型不基于其他模型,则可以在没有预训练权重的情况下对其进行训练,然后将使用随机初始权重。

densenet201_yolo.cfg
https://github.com/AlexeyAB/darknet/blob/master/build/darknet/x64/densenet201_yolo.cfg

resnet50_yolo.cfg
https://github.com/AlexeyAB/darknet/blob/master/build/darknet/x64/resnet50_yolo.cfg

build/darknet/x64/partial.cmd
https://github.com/AlexeyAB/darknet/blob/master/build/darknet/x64/partial.cmd

  • 5
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值