From 5cc2a7e20d99e38aec1724c2f31c166fbf148360 Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Fri, 28 Sep 2018 20:27:30 +0300 Subject: [PATCH] Added mistakes checking --- src/data.c | 7 +++++++ src/demo.c | 7 +++++++ src/detector.c | 4 ++++ src/image.c | 4 ++++ src/network_kernels.cu | 5 ++++- 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/data.c b/src/data.c index 46f86c11..6ca558c8 100644 --- a/src/data.c +++ b/src/data.c @@ -135,6 +135,7 @@ matrix load_image_augment_paths(char **paths, int n, int use_flip, int min, int return X; } +extern int check_mistakes; box_label *read_boxes(char *filename, int *n) { @@ -148,6 +149,7 @@ box_label *read_boxes(char *filename, int *n) char *new_line = "\n"; fwrite(new_line, sizeof(char), strlen(new_line), fw); fclose(fw); + if (check_mistakes) getchar(); *n = 0; return boxes; @@ -352,6 +354,7 @@ void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, sprintf(buff, "echo %s \"Wrong annotation: x = 0 or y = 0\" >> bad_label.list", labelpath); system(buff); ++sub; + if (check_mistakes) getchar(); continue; } if (x <= 0 || x > 1 || y <= 0 || y > 1) { @@ -359,6 +362,7 @@ void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, sprintf(buff, "echo %s \"Wrong annotation: x = %f, y = %f\" >> bad_label.list", labelpath, x, y); system(buff); ++sub; + if (check_mistakes) getchar(); continue; } if (w > 1) { @@ -366,12 +370,14 @@ void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, sprintf(buff, "echo %s \"Wrong annotation: w = %f\" >> bad_label.list", labelpath, w); system(buff); w = 1; + if (check_mistakes) getchar(); } if (h > 1) { printf("\n Wrong annotation: h = %f \n", h); sprintf(buff, "echo %s \"Wrong annotation: h = %f\" >> bad_label.list", labelpath, h); system(buff); h = 1; + if (check_mistakes) getchar(); } if (x == 0) x += lowest_w; if (y == 0) y += lowest_h; @@ -757,6 +763,7 @@ data load_data_detection(int n, char **paths, int m, int w, int h, int c, int bo char buff[256]; sprintf(buff, "echo %s >> bad.list", filename); system(buff); + if (check_mistakes) getchar(); continue; //exit(0); } diff --git a/src/demo.c b/src/demo.c index 4f8c7326..7481660e 100644 --- a/src/demo.c +++ b/src/demo.c @@ -185,6 +185,13 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int probs = (float **)calloc(l.w*l.h*l.n, sizeof(float *)); for(j = 0; j < l.w*l.h*l.n; ++j) probs[j] = (float *)calloc(l.classes, sizeof(float *)); + if (l.classes != demo_classes) { + printf("Parameters don't match: in cfg-file classes=%d, in data-file classes=%d \n", l.classes, demo_classes); + getchar(); + exit(0); + } + + flag_exit = 0; pthread_t fetch_thread; diff --git a/src/detector.c b/src/detector.c index dde0a04f..aff87da4 100644 --- a/src/detector.c +++ b/src/detector.c @@ -31,6 +31,8 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_ #include "http_stream.h" +int check_mistakes; + static int coco_ids[] = {1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,70,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90}; void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show) @@ -941,6 +943,7 @@ void calc_anchors(char *datacfg, int num_of_clusters, int width, int height, int sprintf(buff, "echo \"Wrong label: %s - j = %d, x = %f, y = %f, width = %f, height = %f\" >> bad_label.list", labelpath, j, truth[j].x, truth[j].y, truth[j].w, truth[j].h); system(buff); + if (check_mistakes) getchar(); } number_of_boxes++; rel_width_height_array = realloc(rel_width_height_array, 2 * number_of_boxes * sizeof(float)); @@ -1223,6 +1226,7 @@ void run_detector(int argc, char **argv) { int dont_show = find_arg(argc, argv, "-dont_show"); int show = find_arg(argc, argv, "-show"); + check_mistakes = find_arg(argc, argv, "-check_mistakes"); int http_stream_port = find_int_arg(argc, argv, "-http_port", -1); char *out_filename = find_char_arg(argc, argv, "-out_filename", 0); char *outfile = find_char_arg(argc, argv, "-out", 0); diff --git a/src/image.c b/src/image.c index 7cf3dc05..56c41f6c 100644 --- a/src/image.c +++ b/src/image.c @@ -961,6 +961,8 @@ image ipl_to_image(IplImage* src) return out; } +extern int check_mistakes; + image load_image_cv(char *filename, int channels) { IplImage* src = 0; @@ -983,6 +985,7 @@ image load_image_cv(char *filename, int channels) char *new_line = "\n"; fwrite(new_line, sizeof(char), strlen(new_line), fw); fclose(fw); + if (check_mistakes) getchar(); return make_image(10,10,3); //exit(EXIT_FAILURE); } @@ -1829,6 +1832,7 @@ image load_image_stb(char *filename, int channels) char *new_line = "\n"; fwrite(new_line, sizeof(char), strlen(new_line), fw); fclose(fw); + if (check_mistakes) getchar(); return make_image(10, 10, 3); //exit(EXIT_FAILURE); } diff --git a/src/network_kernels.cu b/src/network_kernels.cu index c592eb98..8cd45fe2 100644 --- a/src/network_kernels.cu +++ b/src/network_kernels.cu @@ -74,10 +74,13 @@ void forward_network_gpu(network net, network_state state) int j; for (j = 0; j < l.out_c; ++j) { image img = make_image(l.out_w, l.out_h, 3); - memcpy(img.data, l.output+ l.out_w*l.out_h*j, l.out_w*l.out_h * 1 * sizeof(float)); + memcpy(img.data, l.output + l.out_w*l.out_h*j, l.out_w*l.out_h * 1 * sizeof(float)); + memcpy(img.data + l.out_w*l.out_h * 1, l.output + l.out_w*l.out_h*j, l.out_w*l.out_h * 1 * sizeof(float)); + memcpy(img.data + l.out_w*l.out_h * 2, l.output + l.out_w*l.out_h*j, l.out_w*l.out_h * 1 * sizeof(float)); char buff[256]; sprintf(buff, "layer-%d slice-%d", i, j); show_image(img, buff); + save_image(img, buff); } cvWaitKey(0); // wait press-key in console cvDestroyAllWindows();