diff --git a/src/detector.c b/src/detector.c index 22f2322d..373fac2f 100644 --- a/src/detector.c +++ b/src/detector.c @@ -222,7 +222,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i i = get_current_batch(net); if (net.cudnn_half) { - if (i < net.burn_in) printf("\n Tensor Cores are disabled until the first %d iterations are reached.", 2*net.burn_in); + if (i < net.burn_in*3) printf("\n Tensor Cores are disabled until the first %d iterations are reached.", 3*net.burn_in); else printf("\n Tensor Cores are used."); } printf("\n %d: %f, %f avg loss, %f rate, %lf seconds, %d images\n", get_current_batch(net), loss, avg_loss, get_current_rate(net), (what_time_is_it_now()-time), i*imgs); @@ -232,6 +232,19 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i int draw_precision = 0; int calc_map_for_each = 4 * train_images_num / (net.batch * net.subdivisions); if (calc_map && (i >= (iter_map + calc_map_for_each) || i == net.max_batches) && i >= net.burn_in && i >= 1000) { + if (l.random) { + printf("Resizing to initial size: %d x %d \n", init_w, init_h); + args.w = init_w; + args.h = init_h; + pthread_join(load_thread, 0); + train = buffer; + load_thread = load_data(args); + int k; + for (k = 0; k < ngpus; ++k) { + resize_network(nets + k, init_w, init_h); + } + net = nets[0]; + } iter_map = i; mean_average_precision = validate_detector_map(datacfg, cfgfile, weightfile, 0.25, 0.5, &net); printf("\n mean_average_precision = %f \n", mean_average_precision); diff --git a/src/image.c b/src/image.c index 344d5160..6092db61 100644 --- a/src/image.c +++ b/src/image.c @@ -737,6 +737,7 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_ if (draw_precision) { static float old_precision = 0; static int iteration_old = 0; + static int text_iteration_old = 0; if(iteration_old == 0) cvPutText(img, "mAP%", cvPoint(0, 12), &font, CV_RGB(255, 0, 0)); cvLine(img, @@ -744,16 +745,19 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_ cvPoint(img_offset + draw_size * (float)current_batch / max_batches, draw_size * (1 - precision)), CV_RGB(255, 0, 0), 1, 8, 0); + if (((int)(old_precision*10) != (int)(precision*10)) || (current_batch - text_iteration_old) >= max_batches/10) { + text_iteration_old = current_batch; + sprintf(char_buff, "%2.0f%% ", precision * 100); + CvFont font3; + cvInitFont(&font3, CV_FONT_HERSHEY_COMPLEX_SMALL, 0.7, 0.7, 0, 5, CV_AA); + cvPutText(img, char_buff, cvPoint(pt1.x - 30, draw_size * (1 - precision) + 15), &font3, CV_RGB(255, 255, 255)); + + CvFont font2; + cvInitFont(&font2, CV_FONT_HERSHEY_COMPLEX_SMALL, 0.7, 0.7, 0, 1, CV_AA); + cvPutText(img, char_buff, cvPoint(pt1.x - 30, draw_size * (1 - precision) + 15), &font2, CV_RGB(200, 0, 0)); + } old_precision = precision; iteration_old = current_batch; - sprintf(char_buff, "%2.0f%% ", precision * 100); - CvFont font3; - cvInitFont(&font3, CV_FONT_HERSHEY_COMPLEX_SMALL, 0.7, 0.7, 0, 5, CV_AA); - cvPutText(img, char_buff, cvPoint(pt1.x - 30, draw_size * (1 - precision) + 15), &font3, CV_RGB(255, 255, 255)); - - CvFont font2; - cvInitFont(&font2, CV_FONT_HERSHEY_COMPLEX_SMALL, 0.7, 0.7, 0, 1, CV_AA); - cvPutText(img, char_buff, cvPoint(pt1.x - 30, draw_size * (1 - precision) + 15), &font2, CV_RGB(200, 0, 0)); } sprintf(char_buff, "current avg loss = %2.4f iteration = %d", avg_loss, current_batch); @@ -763,8 +767,6 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_ pt1.y += 15; cvPutText(img, char_buff, pt1, &font, CV_RGB(0, 0, 0)); - - cvShowImage("average loss", img); int k = cvWaitKey(20); if (k == 's' || current_batch == (max_batches - 1) || current_batch % 100 == 0) {