ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.21k stars 3.45k forks source link

Add support for yolov3-tiny-3l and yolov3-5l #193

Closed drapado closed 5 years ago

drapado commented 5 years ago

Hi, I'm trying to train yolov3-tiny-3l and it seems it's not possible because of the output size differences between normal tiny-yolo and tiny-3l

glenn-jocher commented 5 years ago

I have no idea what you are referring to. Can you at least add some references or details?

drapado commented 5 years ago

These are versions of yolov3 and yolov3-tiny with 5 and 3 yolo output layers respectively, instead of 3 in normal yolov3 and 2 in normal tiny-yolo. They are used for dataset with normal-size and small objects (smaller than 16x16 when resizing)

yolov3_5l.cfg

yolov3-tiny_3l.cfg

glenn-jocher commented 5 years ago

Oh I see. So what's the problem? Just train the damn thing:

python3 train.py --cfg cfg/yolov3-tiny-3l.cfg
Namespace(accumulate=1, backend='nccl', batch_size=16, cfg='cfg/yolov3-tiny-3l.cfg', data_cfg='data/coco.data', dist_url='tcp://127.0.0.1:9999', epochs=273, img_size=416, multi_scale=False, nosave=False, num_workers=4, rank=0, resume=False, transfer=False, var=[8.0, 4.0, 1.0, 64.0, 0.1], world_size=1)

Using cpu 

layer                                     name  gradient   parameters                shape         mu      sigma
    0                          0.conv_0.weight      True          432        [16, 3, 3, 3]   -0.00543      0.076
    1                    0.batch_norm_0.weight      True           16                 [16]     -0.751       2.03
    2                      0.batch_norm_0.bias      True           16                 [16]     -0.644       2.18
    3                          2.conv_2.weight      True         4608       [32, 16, 3, 3]    0.00919      0.203
    4                    2.batch_norm_2.weight      True           32                 [32]   -0.00182     0.0259
    5                      2.batch_norm_2.bias      True           32                 [32]    0.00448     0.0439
    6                          4.conv_4.weight      True        18432       [64, 32, 3, 3]    0.00202      0.104
    7                    4.batch_norm_4.weight      True           64                 [64]     0.0109     0.0211
    8                      4.batch_norm_4.bias      True           64                 [64]   -0.00192     0.0267
    9                          6.conv_6.weight      True        73728      [128, 64, 3, 3]    0.00167     0.0724
   10                    6.batch_norm_6.weight      True          128                [128]   -0.00239     0.0245
   11                      6.batch_norm_6.bias      True          128                [128]   -0.00153     0.0309
   12                          8.conv_8.weight      True       294912     [256, 128, 3, 3]   0.000854     0.0633
   13                    8.batch_norm_8.weight      True          256                [256]   -0.00169     0.0144
   14                      8.batch_norm_8.bias      True          256                [256]   0.000751     0.0138
   15                        10.conv_10.weight      True  1.17965e+06     [512, 256, 3, 3]  -8.54e-05     0.0302
   16                  10.batch_norm_10.weight      True          512                [512]  -0.000812    0.00809
   17                    10.batch_norm_10.bias      True          512                [512]  -0.000975    0.00859
   18                        12.conv_12.weight      True  4.71859e+06    [1024, 512, 3, 3]  -3.89e-05     0.0329
   19                  12.batch_norm_12.weight      True         1024               [1024]   -0.00114     0.0114
   20                    12.batch_norm_12.bias      True         1024               [1024]  -0.000245     0.0109
   21                        13.conv_13.weight      True       262144    [256, 1024, 1, 1]  -5.93e-05    0.00306
   22                  13.batch_norm_13.weight      True          256                [256]  -0.000572   0.000621
   23                    13.batch_norm_13.bias      True          256                [256]   9.75e-06   0.000686
   24                        14.conv_14.weight      True  1.17965e+06     [512, 256, 3, 3]  -0.000202     0.0245
   25                  14.batch_norm_14.weight      True          512                [512]  -2.77e-05   0.000506
   26                    14.batch_norm_14.bias      True          512                [512]   0.000142   0.000404
   27                        15.conv_15.weight      True       130560     [255, 512, 1, 1]  -0.000198    0.00432
   28                          15.conv_15.bias      True          255                [255]  -0.000213    0.00228
   29                        18.conv_18.weight      True        32768     [128, 256, 1, 1]  -0.000302    0.00395
   30                  18.batch_norm_18.weight      True          128                [128]  -0.000537    0.00363
   31                    18.batch_norm_18.bias      True          128                [128]  -4.05e-05    0.00424
   32                        21.conv_21.weight      True       884736     [256, 384, 3, 3]  -0.000279     0.0298
   33                  21.batch_norm_21.weight      True          256                [256]  -0.000149   0.000705
   34                    21.batch_norm_21.bias      True          256                [256]  -0.000235   0.000646
   35                        22.conv_22.weight      True        65280     [255, 256, 1, 1]  -0.000134    0.00421
   36                          22.conv_22.bias      True          255                [255]  -0.000665    0.00557
Model Summary: 37 layers, 8.85237e+06 parameters, 8.85237e+06 gradients

   Epoch       Batch        xy        wh      conf       cls     total  nTargets      time
   0/272      0/7328      1.45     0.148      88.7      8.76        99        72      8.03
   0/272      1/7328      1.38     0.151      88.7      8.77        99       134      6.82
   0/272      2/7328      1.36     0.149      88.7      8.77      98.9       131      6.63
   0/272      3/7328      1.34     0.149      88.7      8.76      98.9        84       7.2
   0/272      4/7328      1.35     0.151      88.7      8.76      98.9       100      6.62
...
H-YunHui commented 5 years ago

@drapado have you successful trained yolov3_5l.cfg in this repo? @glenn-jocher yolov3.cfg and yolov3-spp.cfg output 3 different scales for prediction, could you please add the code for yolov3_5l.cfg, that means outputs 5 different scales for prediction?

drapado commented 5 years ago

@H-YunHui @glenn-jocher Yes, I have successfully trained yolov3-5L and yolov3-tiny-3L without any problem. Everything working straightaway

H-YunHui commented 5 years ago

@drapado use this repo? if not ,could you share your repo?

drapado commented 5 years ago

@H-YunHui Yes I used this repo out of the way. Just change the --cfg option to the yolov3-5L cfg

H-YunHui commented 5 years ago

@drapado have you used the yolov3-5L cfg to train on COCO datasets? what is the map?

glenn-jocher commented 5 years ago

@H-YunHui I don't think 5l will help on COCO, as all of the extra anchors are tiny, from 4,4 to 9,9, so it may be more apt to custom dataset with lots of tiny objects.

I could be wrong of course. If you do train on COCO let us know your results!