[yolo]
mask = 0,1,2
anchors = 8,5, 15,10, 26,13, 20,19, 32,22, 48,16, 56,27, 81,60, 155,119
classes=1
num=9
jitter=.3
ignore_thresh = .7
random=1
yolo层参数 random 作用:
random = 0 :训练过程中保持输入图像尺寸不变。
random = 1 :训练每迭代10次,随机调整输入图像的尺寸。调整规则如下:
rand_coef = 1.4
Random_val = 1.4 or 1/1.4
调整之后输入尺寸: new_input_size = round( Random_val * input_size/32 +1) *32
其中,input_size为cfg中设置的输入尺寸。图像尺寸大小保持32的倍数。
例: input_size = 320
new_input_size = {256, 288, 320, 352, 384, 416, 448, 480}
darknet源码如下,可根据需求调整 输入尺寸变化的 规则。
while (get_current_iteration(net) < net.max_batches) {
if (l.random && count++ % 10 == 0) {
float rand_coef = 1.4;
if (l.random != 1.0) rand_coef = l.random;
printf("Resizing, random_coef = %.2f \n", rand_coef);
float random_val = rand_scale(rand_coef); // *x or /x 缩放系数
int dim_w = roundl(random_val*init_w / net.resize_step + 1) * net.resize_step;
int dim_h = roundl(random_val*init_h / net.resize_step + 1) * net.resize_step;
if (random_val < 1 && (dim_w > init_w || dim_h > init_h)) dim_w = init_w, dim_h = init_h;
int max_dim_w = roundl(rand_coef*init_w / net.resize_step + 1) * net.resize_step;
int max_dim_h = roundl(rand_coef*init_h / net.resize_step + 1) * net.resize_step;
...
...
}