Added mistakes checking

pull/1724/head
AlexeyAB 7 years ago
parent 67f33ff5dc
commit 5cc2a7e20d
  1. 7
      src/data.c
  2. 7
      src/demo.c
  3. 4
      src/detector.c
  4. 4
      src/image.c
  5. 5
      src/network_kernels.cu

@ -135,6 +135,7 @@ matrix load_image_augment_paths(char **paths, int n, int use_flip, int min, int
return X; return X;
} }
extern int check_mistakes;
box_label *read_boxes(char *filename, int *n) box_label *read_boxes(char *filename, int *n)
{ {
@ -148,6 +149,7 @@ box_label *read_boxes(char *filename, int *n)
char *new_line = "\n"; char *new_line = "\n";
fwrite(new_line, sizeof(char), strlen(new_line), fw); fwrite(new_line, sizeof(char), strlen(new_line), fw);
fclose(fw); fclose(fw);
if (check_mistakes) getchar();
*n = 0; *n = 0;
return boxes; 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); sprintf(buff, "echo %s \"Wrong annotation: x = 0 or y = 0\" >> bad_label.list", labelpath);
system(buff); system(buff);
++sub; ++sub;
if (check_mistakes) getchar();
continue; continue;
} }
if (x <= 0 || x > 1 || y <= 0 || y > 1) { 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); sprintf(buff, "echo %s \"Wrong annotation: x = %f, y = %f\" >> bad_label.list", labelpath, x, y);
system(buff); system(buff);
++sub; ++sub;
if (check_mistakes) getchar();
continue; continue;
} }
if (w > 1) { 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); sprintf(buff, "echo %s \"Wrong annotation: w = %f\" >> bad_label.list", labelpath, w);
system(buff); system(buff);
w = 1; w = 1;
if (check_mistakes) getchar();
} }
if (h > 1) { if (h > 1) {
printf("\n Wrong annotation: h = %f \n", h); printf("\n Wrong annotation: h = %f \n", h);
sprintf(buff, "echo %s \"Wrong annotation: h = %f\" >> bad_label.list", labelpath, h); sprintf(buff, "echo %s \"Wrong annotation: h = %f\" >> bad_label.list", labelpath, h);
system(buff); system(buff);
h = 1; h = 1;
if (check_mistakes) getchar();
} }
if (x == 0) x += lowest_w; if (x == 0) x += lowest_w;
if (y == 0) y += lowest_h; 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]; char buff[256];
sprintf(buff, "echo %s >> bad.list", filename); sprintf(buff, "echo %s >> bad.list", filename);
system(buff); system(buff);
if (check_mistakes) getchar();
continue; continue;
//exit(0); //exit(0);
} }

@ -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 *)); 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 *)); 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; flag_exit = 0;
pthread_t fetch_thread; pthread_t fetch_thread;

@ -31,6 +31,8 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_
#include "http_stream.h" #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}; 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) 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", 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); labelpath, j, truth[j].x, truth[j].y, truth[j].w, truth[j].h);
system(buff); system(buff);
if (check_mistakes) getchar();
} }
number_of_boxes++; number_of_boxes++;
rel_width_height_array = realloc(rel_width_height_array, 2 * number_of_boxes * sizeof(float)); 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 dont_show = find_arg(argc, argv, "-dont_show");
int show = find_arg(argc, argv, "-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); int http_stream_port = find_int_arg(argc, argv, "-http_port", -1);
char *out_filename = find_char_arg(argc, argv, "-out_filename", 0); char *out_filename = find_char_arg(argc, argv, "-out_filename", 0);
char *outfile = find_char_arg(argc, argv, "-out", 0); char *outfile = find_char_arg(argc, argv, "-out", 0);

@ -961,6 +961,8 @@ image ipl_to_image(IplImage* src)
return out; return out;
} }
extern int check_mistakes;
image load_image_cv(char *filename, int channels) image load_image_cv(char *filename, int channels)
{ {
IplImage* src = 0; IplImage* src = 0;
@ -983,6 +985,7 @@ image load_image_cv(char *filename, int channels)
char *new_line = "\n"; char *new_line = "\n";
fwrite(new_line, sizeof(char), strlen(new_line), fw); fwrite(new_line, sizeof(char), strlen(new_line), fw);
fclose(fw); fclose(fw);
if (check_mistakes) getchar();
return make_image(10,10,3); return make_image(10,10,3);
//exit(EXIT_FAILURE); //exit(EXIT_FAILURE);
} }
@ -1829,6 +1832,7 @@ image load_image_stb(char *filename, int channels)
char *new_line = "\n"; char *new_line = "\n";
fwrite(new_line, sizeof(char), strlen(new_line), fw); fwrite(new_line, sizeof(char), strlen(new_line), fw);
fclose(fw); fclose(fw);
if (check_mistakes) getchar();
return make_image(10, 10, 3); return make_image(10, 10, 3);
//exit(EXIT_FAILURE); //exit(EXIT_FAILURE);
} }

@ -74,10 +74,13 @@ void forward_network_gpu(network net, network_state state)
int j; int j;
for (j = 0; j < l.out_c; ++j) { for (j = 0; j < l.out_c; ++j) {
image img = make_image(l.out_w, l.out_h, 3); 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]; char buff[256];
sprintf(buff, "layer-%d slice-%d", i, j); sprintf(buff, "layer-%d slice-%d", i, j);
show_image(img, buff); show_image(img, buff);
save_image(img, buff);
} }
cvWaitKey(0); // wait press-key in console cvWaitKey(0); // wait press-key in console
cvDestroyAllWindows(); cvDestroyAllWindows();

Loading…
Cancel
Save