Skip to content

Commit

Permalink
issue #8308: memory leaks in map (#8314)
Browse files Browse the repository at this point in the history
* issue #8308: memory leaks in map

* update the window title with some training stats
  • Loading branch information
stephanecharette authored Jan 9, 2022
1 parent 47aa6cc commit b4d03f8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/coco.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ void validate_coco_recall(char *cfgfile, char *weightfile)

//if (fps) free(fps);
if (id) free(id);
free(truth);
free_image(orig);
free_image(sized);
}
Expand Down
27 changes: 23 additions & 4 deletions src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
if (mean_average_precision > 0) printf("\n Last accuracy mAP@%0.2f = %2.2f %%, best = %2.2f %% ", iou_thresh, mean_average_precision * 100, best_map * 100);
}

#ifndef WIN32
if (mean_average_precision > 0.0) {
printf("\033]2;%d/%d: loss=%0.1f map=%0.2f best=%0.2f hours left=%0.1f\007", iteration, net.max_batches, loss, mean_average_precision, best_map, avg_time);
}
else {
printf("\033]2;%d/%d: loss=%0.1f hours left=%0.1f\007", iteration, net.max_batches, loss, avg_time);
}
#endif

if (net.cudnn_half) {
if (iteration < net.burn_in * 3) fprintf(stderr, "\n Tensor Cores are disabled until the first %d iterations are reached.\n", 3 * net.burn_in);
else fprintf(stderr, "\n Tensor Cores are used.\n");
Expand Down Expand Up @@ -902,6 +911,7 @@ void validate_detector_recall(char *datacfg, char *cfgfile, char *weightfile)
}
//fprintf(stderr, " %s - %s - ", paths[i], labelpath);
fprintf(stderr, "%5d %5d %5d\tRPs/Img: %.2f\tIOU: %.2f%%\tRecall:%.2f%%\n", i, correct, total, (float)proposals / (i + 1), avg_iou * 100 / total, 100.*correct / total);
free(truth);
free(id);
free_image(orig);
free_image(sized);
Expand Down Expand Up @@ -970,13 +980,13 @@ float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, floa
list *plist = get_paths(valid_images);
char **paths = (char **)list_to_array(plist);

list *plist_dif = NULL;
char **paths_dif = NULL;
if (difficult_valid_images) {
list *plist_dif = get_paths(difficult_valid_images);
plist_dif = get_paths(difficult_valid_images);
paths_dif = (char **)list_to_array(plist_dif);
}


layer l = net.layers[net.n - 1];
int k;
for (k = 0; k < net.n; ++k) {
Expand Down Expand Up @@ -1181,6 +1191,8 @@ float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, floa
//if(errors_in_this_image > 0) fwrite(buff, sizeof(char), strlen(buff), reinforcement_fd);

free_detections(dets, nboxes);
free(truth);
free(truth_dif);
free(id);
free_image(val[t]);
free_image(val_resized[t]);
Expand Down Expand Up @@ -1274,7 +1286,6 @@ float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, floa

free(truth_flags);


double mean_average_precision = 0;

for (i = 0; i < classes; ++i) {
Expand Down Expand Up @@ -1362,7 +1373,14 @@ float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, floa
free(detections);
free(truth_classes_count);
free(detection_per_class_count);

free(paths);
free(paths_dif);
free_list_contents(plist);
free_list(plist);
if (plist_dif) {
free_list_contents(plist_dif);
free_list(plist_dif);
}
free(avg_iou_per_class);
free(tp_for_thresh_per_class);
free(fp_for_thresh_per_class);
Expand Down Expand Up @@ -1484,6 +1502,7 @@ void calc_anchors(char *datacfg, int num_of_clusters, int width, int height, int
printf("\r loaded \t image: %d \t box: %d", i + 1, number_of_boxes);
}
free(buff);
free(truth);
}
printf("\n all loaded. \n");
printf("\n calculating k-means++ ...");
Expand Down
1 change: 1 addition & 0 deletions src/yolo.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void validate_yolo_recall(char *cfgfile, char *weightfile)

fprintf(stderr, "%5d %5d %5d\tRPs/Img: %.2f\tIOU: %.2f%%\tRecall:%.2f%%\n", i, correct, total, (float)proposals/(i+1), avg_iou*100/total, 100.*correct/total);
free(id);
free(truth);
free_image(orig);
free_image(sized);
}
Expand Down

0 comments on commit b4d03f8

Please sign in to comment.