From 252e3b1916cfaca0783c9e90efaa55eb07b1a8cd Mon Sep 17 00:00:00 2001 From: Joseph Redmon Date: Sat, 5 Nov 2016 17:27:31 -0700 Subject: [PATCH] :charizard: :charizard: :charizard: --- src/layer.h | 1 + src/parser.c | 2 ++ src/region_layer.c | 10 +++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/layer.h b/src/layer.h index e461fbc6..9aff67fa 100644 --- a/src/layer.h +++ b/src/layer.h @@ -117,6 +117,7 @@ struct layer{ float class_scale; int bias_match; int random; + float thresh; int dontload; int dontloadscales; diff --git a/src/parser.c b/src/parser.c index 09eef42c..26f45d36 100644 --- a/src/parser.c +++ b/src/parser.c @@ -267,6 +267,8 @@ layer parse_region(list *options, size_params params) l.jitter = option_find_float(options, "jitter", .2); l.rescore = option_find_int_quiet(options, "rescore",0); + l.thresh = option_find_float(options, "thresh", .5); + l.coord_scale = option_find_float(options, "coord_scale", 1); l.object_scale = option_find_float(options, "object_scale", 1); l.noobject_scale = option_find_float(options, "noobject_scale", 1); diff --git a/src/region_layer.c b/src/region_layer.c index c3935cad..2702636f 100644 --- a/src/region_layer.c +++ b/src/region_layer.c @@ -141,7 +141,7 @@ void forward_region_layer(const region_layer l, network_state state) } avg_anyobj += l.output[index + 4]; l.delta[index + 4] = l.noobject_scale * ((0 - l.output[index + 4]) * logistic_gradient(l.output[index + 4])); - if(best_iou > .5) l.delta[index + 4] = 0; + if(best_iou > l.thresh) l.delta[index + 4] = 0; if(*(state.net.seen) < 12800){ box truth = {0}; @@ -171,7 +171,7 @@ void forward_region_layer(const region_layer l, network_state state) box truth_shift = truth; truth_shift.x = 0; truth_shift.y = 0; - printf("index %d %d\n",i, j); + //printf("index %d %d\n",i, j); for(n = 0; n < l.n; ++n){ int index = size*(j*l.w*l.n + i*l.n + n) + b*l.outputs; box pred = get_region_box(l.output, l.biases, n, index, i, j, l.w, l.h); @@ -179,7 +179,7 @@ void forward_region_layer(const region_layer l, network_state state) pred.w = l.biases[2*n]; pred.h = l.biases[2*n+1]; } - printf("pred: (%f, %f) %f x %f\n", pred.x, pred.y, pred.w, pred.h); + //printf("pred: (%f, %f) %f x %f\n", pred.x, pred.y, pred.w, pred.h); pred.x = 0; pred.y = 0; float iou = box_iou(pred, truth_shift); @@ -189,7 +189,7 @@ void forward_region_layer(const region_layer l, network_state state) best_n = n; } } - printf("%d %f (%f, %f) %f x %f\n", best_n, best_iou, truth.x, truth.y, truth.w, truth.h); + //printf("%d %f (%f, %f) %f x %f\n", best_n, best_iou, truth.x, truth.y, truth.w, truth.h); float iou = delta_region_box(truth, l.output, l.biases, best_n, best_index, i, j, l.w, l.h, l.delta, l.coord_scale); if(iou > .5) recall += 1; @@ -230,7 +230,7 @@ void forward_region_layer(const region_layer l, network_state state) ++count; } } - printf("\n"); + //printf("\n"); reorg(l.delta, l.w*l.h, size*l.n, l.batch, 0); *(l.cost) = pow(mag_array(l.delta, l.outputs * l.batch), 2); printf("Region Avg IOU: %f, Class: %f, Obj: %f, No Obj: %f, Avg Recall: %f, count: %d\n", avg_iou/count, avg_cat/count, avg_obj/count, avg_anyobj/(l.w*l.h*l.n*l.batch), recall/count, count);