From 3ebcc647b651a4a3c717eff2a3087127e5707e0c Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 14 May 2018 09:20:38 +0000
Subject: [PATCH] Fixed network resizing (random=1) for non-square networks

---
 src/detector.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/detector.c b/src/detector.c
index 71ede10..2b54a4a 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -66,6 +66,11 @@
     srand(time(0));
     network net = nets[0];
 
+	if ((net.batch * net.subdivisions) == 1) {
+		printf("\n Error: You set incorrect value batch=1 for Training! You should set batch=64 subdivision=64 \n");
+		getchar();
+	}
+
     int imgs = net.batch * net.subdivisions * ngpus;
     printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
     data train, buffer;
@@ -121,12 +126,16 @@
     while(get_current_batch(net) < net.max_batches){
 		if(l.random && count++%10 == 0){
             printf("Resizing\n");
-			int dim = (rand() % 12 + (init_w/32 - 5)) * 32;	// +-160
-            //if (get_current_batch(net)+100 > net.max_batches) dim = 544;
+			//int dim = (rand() % 12 + (init_w/32 - 5)) * 32;	// +-160
             //int dim = (rand() % 4 + 16) * 32;
-            printf("%d\n", dim);
-            args.w = dim;
-            args.h = dim;
+			//if (get_current_batch(net)+100 > net.max_batches) dim = 544;
+			int random_val = rand() % 12;
+			int dim_w = (random_val + (init_w / 32 - 5)) * 32;	// +-160
+			int dim_h = (random_val + (init_h / 32 - 5)) * 32;	// +-160
+
+			printf("%d x %d \n", dim_w, dim_h);
+			args.w = dim_w;
+			args.h = dim_h;
 
             pthread_join(load_thread, 0);
             train = buffer;
@@ -134,7 +143,7 @@
             load_thread = load_data(args);
 
             for(i = 0; i < ngpus; ++i){
-                resize_network(nets + i, dim, dim);
+                resize_network(nets + i, dim_w, dim_h);
             }
             net = nets[0];
         }

--
Gitblit v1.10.0