From 989ab8c38a02fa7ea9c25108151736c62e81c972 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 24 Apr 2015 17:27:50 +0000
Subject: [PATCH] IOU loss function
---
src/detection.c | 60 ++++++++++++++++++++++++++++++------------------------------
1 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/detection.c b/src/detection.c
index c61c799..f61da67 100644
--- a/src/detection.c
+++ b/src/detection.c
@@ -81,9 +81,9 @@
if (imgnet){
plist = get_paths("/home/pjreddie/data/imagenet/det.train.list");
}else{
- //plist = get_paths("/home/pjreddie/data/voc/trainall.txt");
+ plist = get_paths("/home/pjreddie/data/voc/trainall.txt");
//plist = get_paths("/home/pjreddie/data/coco/trainval.txt");
- plist = get_paths("/home/pjreddie/data/voc/all2007-2012.txt");
+ //plist = get_paths("/home/pjreddie/data/voc/all2007-2012.txt");
}
paths = (char **)list_to_array(plist);
pthread_t load_thread = load_data_detection_thread(imgs, paths, plist->size, classes, net.w, net.h, side, side, background, &buffer);
@@ -95,12 +95,12 @@
train = buffer;
load_thread = load_data_detection_thread(imgs, paths, plist->size, classes, net.w, net.h, side, side, background, &buffer);
-/*
- image im = float_to_image(net.w, net.h, 3, train.X.vals[114]);
- image copy = copy_image(im);
- draw_detection(copy, train.y.vals[114], 7);
- free_image(copy);
- */
+ /*
+ image im = float_to_image(net.w, net.h, 3, train.X.vals[114]);
+ image copy = copy_image(im);
+ draw_detection(copy, train.y.vals[114], 7);
+ free_image(copy);
+ */
printf("Loaded: %lf seconds\n", sec(clock()-time));
time=clock();
@@ -120,30 +120,30 @@
void predict_detections(network net, data d, float threshold, int offset, int classes, int nuisance, int background, int num_boxes, int per_box)
{
- matrix pred = network_predict_data(net, d);
- int j, k, class;
- for(j = 0; j < pred.rows; ++j){
- for(k = 0; k < pred.cols; k += per_box){
- float scale = 1.;
- int index = k/per_box;
- int row = index / num_boxes;
- int col = index % num_boxes;
- if (nuisance) scale = 1.-pred.vals[j][k];
- for (class = 0; class < classes; ++class){
- int ci = k+classes+background+nuisance;
- float y = (pred.vals[j][ci + 0] + row)/num_boxes;
- float x = (pred.vals[j][ci + 1] + col)/num_boxes;
- float h = pred.vals[j][ci + 2]; //* distance_from_edge(row, num_boxes);
- h = h*h;
- float w = pred.vals[j][ci + 3]; //* distance_from_edge(col, num_boxes);
- w = w*w;
- float prob = scale*pred.vals[j][k+class+background+nuisance];
- if(prob < threshold) continue;
- printf("%d %d %f %f %f %f %f\n", offset + j, class, prob, y, x, h, w);
- }
+ matrix pred = network_predict_data(net, d);
+ int j, k, class;
+ for(j = 0; j < pred.rows; ++j){
+ for(k = 0; k < pred.cols; k += per_box){
+ float scale = 1.;
+ int index = k/per_box;
+ int row = index / num_boxes;
+ int col = index % num_boxes;
+ if (nuisance) scale = 1.-pred.vals[j][k];
+ for (class = 0; class < classes; ++class){
+ int ci = k+classes+background+nuisance;
+ float y = (pred.vals[j][ci + 0] + row)/num_boxes;
+ float x = (pred.vals[j][ci + 1] + col)/num_boxes;
+ float h = pred.vals[j][ci + 2]; //* distance_from_edge(row, num_boxes);
+ h = h*h;
+ float w = pred.vals[j][ci + 3]; //* distance_from_edge(col, num_boxes);
+ w = w*w;
+ float prob = scale*pred.vals[j][k+class+background+nuisance];
+ if(prob < threshold) continue;
+ printf("%d %d %f %f %f %f %f\n", offset + j, class, prob, y, x, h, w);
}
}
- free_matrix(pred);
+ }
+ free_matrix(pred);
}
void validate_detection(char *cfgfile, char *weightfile)
--
Gitblit v1.10.0