From 8ed0a5538e04002c95ff0757791c52b4ec9a3e96 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Tue, 21 Jul 2015 18:38:36 +0000
Subject: [PATCH] faster resize?
---
src/data.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/data.c b/src/data.c
index dafcc98..2b61853 100644
--- a/src/data.c
+++ b/src/data.c
@@ -140,7 +140,7 @@
void fill_truth_detection(char *path, float *truth, int classes, int num_boxes, int flip, int background, float dx, float dy, float sx, float sy)
{
- char *labelpath = find_replace(path, "detection_images", "labels");
+ char *labelpath = find_replace(path, "JPEGImages", "labels");
labelpath = find_replace(labelpath, ".jpg", ".txt");
labelpath = find_replace(labelpath, ".JPEG", ".txt");
int count = 0;
@@ -332,7 +332,7 @@
++count;
}
}
- if(count != 1) printf("%d, %s\n", count, path);
+ if(count != 1) printf("Too many or too few labels: %d, %s\n", count, path);
}
matrix load_labels_paths(char **paths, int n, char **labels, int k)
@@ -425,10 +425,18 @@
d.X.vals = calloc(d.X.rows, sizeof(float*));
d.X.cols = h*w*3;
+ clock_t time;
+ clock_t load = 0;
+ clock_t resize = 0;
+ clock_t crop = 0;
+
int k = num_boxes*num_boxes*(4+classes+background);
d.y = make_matrix(n, k);
for(i = 0; i < n; ++i){
+ time=clock();
image orig = load_image_color(random_paths[i], 0, 0);
+ load += clock() - time;
+ time = clock();
int oh = orig.h;
int ow = orig.w;
@@ -456,17 +464,26 @@
int flip = rand_r(&data_seed)%2;
image cropped = crop_image(orig, pleft, ptop, swidth, sheight);
+
+ crop += clock() - time;
+ time = clock();
+
float dx = ((float)pleft/ow)/sx;
float dy = ((float)ptop /oh)/sy;
- free_image(orig);
image sized = resize_image(cropped, w, h);
- free_image(cropped);
if(flip) flip_image(sized);
d.X.vals[i] = sized.data;
+ resize += clock() - time;
+ time = clock();
+
fill_truth_detection(random_paths[i], d.y.vals[i], classes, num_boxes, flip, background, dx, dy, 1./sx, 1./sy);
+
+ free_image(orig);
+ free_image(cropped);
}
+ printf("load: %f, crop: %f, resize: %f\n", sec(load), sec(crop), sec(resize));
free(random_paths);
return d;
}
--
Gitblit v1.10.0