AlexeyAB
2018-03-08 a6c51e3b758aee7fd3a6f1d37daa8dcad4891e52
Fixes for small objects. And fixes of densenet201_yolo.cfg, resnet50_yolo.cfg, resnet152_yolo.cfg
7 files modified
85 ■■■■■ changed files
build/darknet/x64/densenet201_yolo.cfg 31 ●●●●● patch | view | raw | blame | history
build/darknet/x64/partial.cmd 4 ●●●● patch | view | raw | blame | history
build/darknet/x64/resnet152_yolo.cfg 19 ●●●●● patch | view | raw | blame | history
build/darknet/x64/resnet50_yolo.cfg 19 ●●●● patch | view | raw | blame | history
src/data.c 2 ●●● patch | view | raw | blame | history
src/detector.c 2 ●●● patch | view | raw | blame | history
src/region_layer.c 8 ●●●● patch | view | raw | blame | history
build/darknet/x64/densenet201_yolo.cfg
@@ -1,30 +1,21 @@
[net]
# Training
batch=64
subdivisions=32
# Testing
#batch=1
#subdivisions=1
subdivisions=8
height=416
width=416
#max_crop=448
channels=3
momentum=0.9
decay=0.0005
burn_in=1000
learning_rate=0.1
policy=poly
power=4
max_batches=1600000
angle=7
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
saturation=.75
exposure=.75
aspect=.75
learning_rate=0.0001
max_batches = 45000
policy=steps
steps=100,25000,35000
scales=10,.1,.1
[convolutional]
batch_normalize=1
@@ -1935,7 +1926,7 @@
[route]
layers=-1,-3
stopbackward=1
#stopbackward=1
[convolutional]
build/darknet/x64/partial.cmd
@@ -6,6 +6,10 @@
darknet.exe partial cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights tiny-yolo-voc.conv.13 13
darknet.exe partial cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights tiny-yolo-voc.conv.12 12
darknet.exe partial cfg/yolo-voc.cfg yolo-voc.weights yolo-voc.conv.23 23
build/darknet/x64/resnet152_yolo.cfg
@@ -5,22 +5,17 @@
width=416
channels=3
momentum=0.9
decay=0.0001
#decay=0.0005
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.01
max_batches = 90000
learning_rate=0.0001
max_batches = 45000
policy=steps
steps=60000,80000
scales=.1,.1
#learning_rate=0.0001
#steps=100,25000,35000
#scales=10,.1,.1
steps=100,25000,35000
scales=10,.1,.1
[convolutional]
batch_normalize=1
@@ -1436,7 +1431,7 @@
[shortcut]
from=-4
activation=leaky
stopbackward=1
#stopbackward=1
@@ -1466,7 +1461,7 @@
softmax=1
jitter=.3
rescore=1
focal_loss=1
#focal_loss=1
object_scale=5
noobject_scale=1
build/darknet/x64/resnet50_yolo.cfg
@@ -1,18 +1,15 @@
[net]
# Training
batch=64
subdivisions=16
# Testing
#batch=1
#subdivisions=1
subdivisions=8
height=416
width=416
#max_crop=448
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.0001
max_batches = 45000
@@ -20,12 +17,6 @@
steps=100,25000,35000
scales=10,.1,.1
angle=7
hue=.1
saturation=.75
exposure=.75
aspect=.75
[convolutional]
batch_normalize=1
filters=64
src/data.c
@@ -326,7 +326,7 @@
        id = boxes[i].id;
        // not detect small objects
        if ((w < 0.01 || h < 0.01)) continue;
        if ((w < 0.001 || h < 0.001)) { printf("small w = %f, h = %f \n", w, h); continue; }
        truth[i*5+0] = x;
        truth[i*5+1] = y;
src/detector.c
@@ -918,7 +918,7 @@
        float box_h = points->data.fl[i * 2 + 1];
        //int cluster_idx = labels->data.i[i];      
        int cluster_idx = 0;
        float min_dist = 1000000;
        float min_dist = FLT_MAX;
        for (j = 0; j < num_of_clusters; ++j) {
            float anchor_w = centers->data.fl[j * 2];
            float anchor_h = centers->data.fl[j * 2 + 1];
src/region_layer.c
@@ -131,11 +131,11 @@
        // Focal loss
        if (focal_loss) {
            // Focal Loss for Dense Object Detection: http://blog.csdn.net/linmingan/article/details/77885832
            //printf("Used Focal-loss \n");
            float alpha = 0.5;  // 0.25
            float gamma = 2.0;
            float alpha = 0.5;  // 0.25 or 0.5
            //float gamma = 2;  // hardcoded in many places of the grad-formula
            int ti = index + class_id;
            float grad = -gamma * (1 - output[ti])*logf(fmaxf(output[ti], 0.0000001))*output[ti] + (1 - output[ti])*(1 - output[ti]);
            float grad = -2 * (1 - output[ti])*logf(fmaxf(output[ti], 0.0000001))*output[ti] + (1 - output[ti])*(1 - output[ti]);
            for (n = 0; n < classes; ++n) {
                delta[index + n] = scale * (((n == class_id) ? 1 : 0) - output[index + n]);