From 9fbd1936ebed466aad50c52989b92d5e3fedc099 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 30 Mar 2018 11:32:41 +0000
Subject: [PATCH] small_object can be used in [net] in cfg-file for objects 1x1 pix on FullHD image

---
 src/network.h  |    1 +
 src/parser.c   |    2 +-
 src/data.c     |    6 +++---
 src/detector.c |    2 +-
 src/layer.h    |    1 -
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/data.c b/src/data.c
index 88d5720..f087cd4 100644
--- a/src/data.c
+++ b/src/data.c
@@ -308,8 +308,8 @@
     box_label *boxes = read_boxes(labelpath, &count);
 	if (small_object == 1) {
 		for (i = 0; i < count; ++i) {
-			if (boxes[i].w < 0.01) boxes[i].w = 0.01;
-			if (boxes[i].h < 0.01) boxes[i].h = 0.01;
+			if (boxes[i].w < 0.001F) boxes[i].w = 0.001F;
+			if (boxes[i].h < 0.001F) boxes[i].h = 0.001F;
 		}
 	}
     randomize_boxes(boxes, count);
@@ -326,7 +326,7 @@
         id = boxes[i].id;
 
 		// not detect small objects
-		if ((w < 0.001 || h < 0.001)) continue;
+		if ((w < 0.001F || h < 0.001F)) continue;
 
         truth[i*5+0] = x;
         truth[i*5+1] = y;
diff --git a/src/detector.c b/src/detector.c
index ac84c59..b588b6d 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -88,7 +88,7 @@
     args.classes = classes;
     args.jitter = jitter;
     args.num_boxes = l.max_boxes;
-	args.small_object = l.small_object;
+	args.small_object = net.small_object;
     args.d = &buffer;
     args.type = DETECTION_DATA;
 	args.threads = 64;	// 8
diff --git a/src/layer.h b/src/layer.h
index 91b893a..5d55e1c 100644
--- a/src/layer.h
+++ b/src/layer.h
@@ -78,7 +78,6 @@
     int out_h, out_w, out_c;
     int n;
     int max_boxes;
-	int small_object;
     int groups;
     int size;
     int side;
diff --git a/src/network.h b/src/network.h
index f3bb542..5b405c4 100644
--- a/src/network.h
+++ b/src/network.h
@@ -57,6 +57,7 @@
     float exposure;
     float saturation;
     float hue;
+	int small_object;
 
     int gpu_index;
     tree *hierarchy;
diff --git a/src/parser.c b/src/parser.c
index fd3d691..5a111bf 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -311,7 +311,6 @@
     l.log = option_find_int_quiet(options, "log", 0);
     l.sqrt = option_find_int_quiet(options, "sqrt", 0);
 
-	l.small_object = option_find_int_quiet(options, "small_object", 0);
     l.softmax = option_find_int(options, "softmax", 0);
 	l.focal_loss = option_find_int_quiet(options, "focal_loss", 0);
     //l.max_boxes = option_find_int_quiet(options, "max",30);
@@ -622,6 +621,7 @@
     net->max_crop = option_find_int_quiet(options, "max_crop",net->w*2);
     net->min_crop = option_find_int_quiet(options, "min_crop",net->w);
 
+	net->small_object = option_find_int_quiet(options, "small_object", 0);
     net->angle = option_find_float_quiet(options, "angle", 0);
     net->aspect = option_find_float_quiet(options, "aspect", 1);
     net->saturation = option_find_float_quiet(options, "saturation", 1);

--
Gitblit v1.10.0