From e345b8793c4dd8c28e0854145ac15b912b771bc6 Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Tue, 5 Nov 2019 16:06:24 +0300 Subject: [PATCH] Fixed ./darknet partial for Anti-aliasing --- src/convolutional_layer.c | 19 ++++--------------- src/maxpool_layer.c | 19 ++++--------------- src/parser.c | 2 ++ 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/convolutional_layer.c b/src/convolutional_layer.c index 6818b603..bf5beac7 100644 --- a/src/convolutional_layer.c +++ b/src/convolutional_layer.c @@ -607,19 +607,6 @@ convolutional_layer make_convolutional_layer(int batch, int steps, int h, int w, } else { for (i = 0; i < blur_nweights; i += (blur_size*blur_size)) { - /* - l.input_layer->weights[i + 0] = 0; - l.input_layer->weights[i + 1] = 0; - l.input_layer->weights[i + 2] = 0; - - l.input_layer->weights[i + 3] = 0; - l.input_layer->weights[i + 4] = 1; - l.input_layer->weights[i + 5] = 0; - - l.input_layer->weights[i + 6] = 0; - l.input_layer->weights[i + 7] = 0; - l.input_layer->weights[i + 8] = 0; - */ l.input_layer->weights[i + 0] = 1 / 16.f; l.input_layer->weights[i + 1] = 2 / 16.f; l.input_layer->weights[i + 2] = 1 / 16.f; @@ -635,8 +622,10 @@ convolutional_layer make_convolutional_layer(int batch, int steps, int h, int w, } for (i = 0; i < n; ++i) l.input_layer->biases[i] = 0; #ifdef GPU - l.input_antialiasing_gpu = cuda_make_array(NULL, l.batch*l.outputs); - push_convolutional_layer(*(l.input_layer)); + if (gpu_index >= 0) { + l.input_antialiasing_gpu = cuda_make_array(NULL, l.batch*l.outputs); + push_convolutional_layer(*(l.input_layer)); + } #endif // GPU } diff --git a/src/maxpool_layer.c b/src/maxpool_layer.c index dca9c1b1..a05074ec 100644 --- a/src/maxpool_layer.c +++ b/src/maxpool_layer.c @@ -127,19 +127,6 @@ maxpool_layer make_maxpool_layer(int batch, int h, int w, int c, int size, int s } else { for (i = 0; i < blur_nweights; i += (blur_size*blur_size)) { - /* - l.input_layer->weights[i + 0] = 0; - l.input_layer->weights[i + 1] = 0; - l.input_layer->weights[i + 2] = 0; - - l.input_layer->weights[i + 3] = 0; - l.input_layer->weights[i + 4] = 1; - l.input_layer->weights[i + 5] = 0; - - l.input_layer->weights[i + 6] = 0; - l.input_layer->weights[i + 7] = 0; - l.input_layer->weights[i + 8] = 0; - */ l.input_layer->weights[i + 0] = 1 / 16.f; l.input_layer->weights[i + 1] = 2 / 16.f; l.input_layer->weights[i + 2] = 1 / 16.f; @@ -155,8 +142,10 @@ maxpool_layer make_maxpool_layer(int batch, int h, int w, int c, int size, int s } for (i = 0; i < l.out_c; ++i) l.input_layer->biases[i] = 0; #ifdef GPU - l.input_antialiasing_gpu = cuda_make_array(NULL, l.batch*l.outputs); - push_convolutional_layer(*(l.input_layer)); + if (gpu_index >= 0) { + l.input_antialiasing_gpu = cuda_make_array(NULL, l.batch*l.outputs); + push_convolutional_layer(*(l.input_layer)); + } #endif // GPU } diff --git a/src/parser.c b/src/parser.c index 2cf295f0..edda54d1 100644 --- a/src/parser.c +++ b/src/parser.c @@ -951,6 +951,8 @@ network parse_network_cfg_custom(char *filename, int batch, int time_steps) params.inputs = net.inputs; if (batch > 0) net.batch = batch; if (time_steps > 0) net.time_steps = time_steps; + if (net.batch < 1) net.batch = 1; + if (net.time_steps < 1) net.time_steps = 1; if (net.batch < net.time_steps) net.batch = net.time_steps; params.batch = net.batch; params.time_steps = net.time_steps;