From 35cc0aaa15b991b348cc8d9623eed5d4f8a1e435 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Fri, 30 Mar 2018 12:51:54 +0000
Subject: [PATCH] Added max_boxes for yolo v3

---
 src/parser.c     |    5 +++--
 src/yolo_layer.h |    2 +-
 src/yolo_layer.c |    6 ++++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index 5a111bf..4de8aeb 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -268,10 +268,11 @@
 
 	char *a = option_find_str(options, "mask", 0);
 	int *mask = parse_yolo_mask(a, &num);
-	layer l = make_yolo_layer(params.batch, params.w, params.h, num, total, mask, classes);
+	int max_boxes = option_find_int_quiet(options, "max", 30);
+	layer l = make_yolo_layer(params.batch, params.w, params.h, num, total, mask, classes, max_boxes);
 	assert(l.outputs == params.inputs);
 
-	l.max_boxes = option_find_int_quiet(options, "max", 90);
+	//l.max_boxes = option_find_int_quiet(options, "max", 90);
 	l.jitter = option_find_float(options, "jitter", .2);
 
 	l.ignore_thresh = option_find_float(options, "ignore_thresh", .5);
diff --git a/src/yolo_layer.c b/src/yolo_layer.c
index 2925b26..1ec04b8 100644
--- a/src/yolo_layer.c
+++ b/src/yolo_layer.c
@@ -10,7 +10,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-layer make_yolo_layer(int batch, int w, int h, int n, int total, int *mask, int classes)
+layer make_yolo_layer(int batch, int w, int h, int n, int total, int *mask, int classes, int max_boxes)
 {
     int i;
     layer l = {0};
@@ -38,7 +38,9 @@
     l.bias_updates = calloc(n*2, sizeof(float));
     l.outputs = h*w*n*(classes + 4 + 1);
     l.inputs = l.outputs;
-    l.truths = 90*(4 + 1);
+	l.max_boxes = max_boxes;
+	printf(" l.max_boxes = %d \n", l.max_boxes);
+    l.truths = l.max_boxes*(4 + 1);	// 90*(4 + 1);
     l.delta = calloc(batch*l.outputs, sizeof(float));
     l.output = calloc(batch*l.outputs, sizeof(float));
     for(i = 0; i < total*2; ++i){
diff --git a/src/yolo_layer.h b/src/yolo_layer.h
index 035c55b..fb9712a 100644
--- a/src/yolo_layer.h
+++ b/src/yolo_layer.h
@@ -5,7 +5,7 @@
 #include "layer.h"
 #include "network.h"
 
-layer make_yolo_layer(int batch, int w, int h, int n, int total, int *mask, int classes);
+layer make_yolo_layer(int batch, int w, int h, int n, int total, int *mask, int classes, int max_boxes);
 void forward_yolo_layer(const layer l, network_state state);
 void backward_yolo_layer(const layer l, network_state state);
 void resize_yolo_layer(layer *l, int w, int h);

--
Gitblit v1.10.0