AlexeyAB
2018-03-30 23cb35e6c8eae8b59fab161036ae3f417a55c8db
src/data.c
@@ -292,7 +292,8 @@
    free(boxes);
}
void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, int flip, float dx, float dy, float sx, float sy, int small_object)
void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, int flip, float dx, float dy, float sx, float sy,
   int small_object, int net_w, int net_h)
{
    char labelpath[4096];
    find_replace(path, "images", "labels", labelpath);
@@ -307,9 +308,12 @@
   int i;
    box_label *boxes = read_boxes(labelpath, &count);
   if (small_object == 1) {
      float lowest_w = 1.F / net_w;
      float lowest_h = 1.F / net_h;
      printf(" lowest_w = %f, lowest_h = %f \n", lowest_w, lowest_h);
      for (i = 0; i < count; ++i) {
         if (boxes[i].w < 0.01) boxes[i].w = 0.01;
         if (boxes[i].h < 0.01) boxes[i].h = 0.01;
         if (boxes[i].w < lowest_w) boxes[i].w = lowest_w;
         if (boxes[i].h < lowest_h) boxes[i].h = lowest_h;
      }
   }
    randomize_boxes(boxes, count);
@@ -326,7 +330,7 @@
        id = boxes[i].id;
      // not detect small objects
      if ((w < 0.001 || h < 0.001)) continue;
      if ((w < 0.001F || h < 0.001F)) continue;
        truth[i*5+0] = x;
        truth[i*5+1] = y;
@@ -738,7 +742,7 @@
      //show_image(ai, "aug");
      //cvWaitKey(0);
        fill_truth_detection(filename, boxes, d.y.vals[i], classes, flip, dx, dy, 1./sx, 1./sy, small_object);
        fill_truth_detection(filename, boxes, d.y.vals[i], classes, flip, dx, dy, 1./sx, 1./sy, small_object, w, h);
      cvReleaseImage(&src);
    }
@@ -789,7 +793,7 @@
      random_distort_image(sized, hue, saturation, exposure);
      d.X.vals[i] = sized.data;
      fill_truth_detection(random_paths[i], boxes, d.y.vals[i], classes, flip, dx, dy, 1. / sx, 1. / sy, small_object);
      fill_truth_detection(random_paths[i], boxes, d.y.vals[i], classes, flip, dx, dy, 1. / sx, 1. / sy, small_object, w, h);
      free_image(orig);
      free_image(cropped);
@@ -827,6 +831,9 @@
    } else if (a.type == IMAGE_DATA){
        *(a.im) = load_image_color(a.path, 0, 0);
        *(a.resized) = resize_image(*(a.im), a.w, a.h);
   }else if (a.type == LETTERBOX_DATA) {
      *(a.im) = load_image_color(a.path, 0, 0);
      *(a.resized) = letterbox_image(*(a.im), a.w, a.h);
    } else if (a.type == TAG_DATA){
        *a.d = load_data_tag(a.paths, a.n, a.m, a.classes, a.min, a.max, a.size, a.angle, a.aspect, a.hue, a.saturation, a.exposure);
    }