From c2c8595b083ec3586a99bb913b8a986e81e3a42a Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Thu, 19 Apr 2018 14:47:39 +0300 Subject: [PATCH] Fixed detection and validate(recall, map) for .png and .bmp images. --- build/darknet/x64/partial.cmd | 3 +++ src/data.c | 1 + src/detector.c | 13 ++++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build/darknet/x64/partial.cmd b/build/darknet/x64/partial.cmd index de63ee6e..9b12bae8 100644 --- a/build/darknet/x64/partial.cmd +++ b/build/darknet/x64/partial.cmd @@ -15,6 +15,9 @@ darknet.exe partial cfg/yolov2-tiny.cfg yolov2-tiny.weights yolov2-tiny.conv.13 darknet.exe partial cfg/yolo-voc.cfg yolo-voc.weights yolo-voc.conv.23 23 +darknet.exe partial cfg/yolov2.cfg yolov2.weights yolov2.conv.23 23 + + darknet.exe partial cfg/yolo9000.cfg yolo9000.weights yolo9000.conv.22 22 diff --git a/src/data.c b/src/data.c index abdb0433..a9dba1dd 100644 --- a/src/data.c +++ b/src/data.c @@ -302,6 +302,7 @@ void fill_truth_detection(char *path, int num_boxes, float *truth, int classes, find_replace(labelpath, "raw", "labels", labelpath); find_replace(labelpath, ".jpg", ".txt", labelpath); find_replace(labelpath, ".png", ".txt", labelpath); + find_replace(labelpath, ".bmp", ".txt", labelpath); find_replace(labelpath, ".JPG", ".txt", labelpath); find_replace(labelpath, ".JPEG", ".txt", labelpath); int count = 0; diff --git a/src/detector.c b/src/detector.c index 13fb5b48..766819f1 100644 --- a/src/detector.c +++ b/src/detector.c @@ -460,6 +460,9 @@ void validate_detector_recall(char *datacfg, char *cfgfile, char *weightfile) find_replace(path, "images", "labels", labelpath); find_replace(labelpath, "JPEGImages", "labels", labelpath); find_replace(labelpath, ".jpg", ".txt", labelpath); + find_replace(labelpath, ".png", ".txt", labelpath); + find_replace(labelpath, ".bmp", ".txt", labelpath); + find_replace(labelpath, ".JPG", ".txt", labelpath); find_replace(labelpath, ".JPEG", ".txt", labelpath); int num_labels = 0; @@ -484,7 +487,7 @@ void validate_detector_recall(char *datacfg, char *cfgfile, char *weightfile) ++correct; } } - fprintf(stderr, " %s - %s - ", paths[i], labelpath); + //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(id); free_image(orig); @@ -614,8 +617,10 @@ void validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, float find_replace(path, "images", "labels", labelpath); find_replace(labelpath, "JPEGImages", "labels", labelpath); find_replace(labelpath, ".jpg", ".txt", labelpath); - find_replace(labelpath, ".JPEG", ".txt", labelpath); find_replace(labelpath, ".png", ".txt", labelpath); + find_replace(labelpath, ".bmp", ".txt", labelpath); + find_replace(labelpath, ".JPG", ".txt", labelpath); + find_replace(labelpath, ".JPEG", ".txt", labelpath); int num_labels = 0; box_label *truth = read_boxes(labelpath, &num_labels); int i, j; @@ -861,8 +866,10 @@ void calc_anchors(char *datacfg, int num_of_clusters, int width, int height, int find_replace(path, "images", "labels", labelpath); find_replace(labelpath, "JPEGImages", "labels", labelpath); find_replace(labelpath, ".jpg", ".txt", labelpath); - find_replace(labelpath, ".JPEG", ".txt", labelpath); find_replace(labelpath, ".png", ".txt", labelpath); + find_replace(labelpath, ".bmp", ".txt", labelpath); + find_replace(labelpath, ".JPG", ".txt", labelpath); + find_replace(labelpath, ".JPEG", ".txt", labelpath); int num_labels = 0; box_label *truth = read_boxes(labelpath, &num_labels); //printf(" new path: %s \n", labelpath);