From 3b5bc830ee23afdfd41d2c31c022fb6ea71b9d9d Mon Sep 17 00:00:00 2001 From: Roberto Larcher Date: Tue, 5 Mar 2019 18:43:51 +0100 Subject: [PATCH 1/3] added extra script that create the union between detections and predictions --- extra/union-gt-and-pred.py | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 extra/union-gt-and-pred.py diff --git a/extra/union-gt-and-pred.py b/extra/union-gt-and-pred.py new file mode 100644 index 000000000..a12b66f14 --- /dev/null +++ b/extra/union-gt-and-pred.py @@ -0,0 +1,58 @@ +import sys +import os +import glob + +## This script ensures same number of files in ground-truth and predicted folder. +## When you encounter file not found error, it's usually because you have +## mismatched numbers of ground-truth and predicted files. +## You can use this script to move ground-truth and predicted files that are +## not in the intersection into a backup folder (backup_no_matches_found). +## This will retain only files that have the same name in both folders. + +# change directory to the one with the files to be changed +path_to_gt = '../ground-truth' +path_to_pred = '../predicted' + +os.chdir(path_to_gt) +gt_files = glob.glob('*.txt') +if len(gt_files) == 0: + print("Error: no .txt files found in", path_to_gt) + sys.exit() +os.chdir(path_to_pred) +pred_files = glob.glob('*.txt') +if len(pred_files) == 0: + print("Error: no .txt files found in", path_to_pred) + sys.exit() + +gt_files = set(gt_files) +pred_files = set(pred_files) +print('total ground-truth files:', len(gt_files)) +print('total predicted files:', len(pred_files)) +print() + +gt_backup = gt_files - pred_files +pred_backup = pred_files - gt_files + +print("gt_backup:", gt_backup) +print("pre_backup:", pred_backup) + +def backup(src_folder, backup_files, dst_folder): + # non-intersection files (txt format) will be moved to a backup folder + if not backup_files: + print('No backup required for', src_folder) + return + os.chdir(src_folder) + ## create the backup dir if it doesn't exist already + for file in backup_files: + open(dst_folder + '/' + file, 'w').close() + +backup(path_to_gt, gt_backup, path_to_pred) +backup(path_to_pred, pred_backup, path_to_gt) +if gt_backup: + print('total ground-truth backup files:', len(gt_backup)) +if pred_backup: + print('total predicted backup files:', len(pred_backup)) + +intersection = gt_files | pred_files +print('total union files:', len(intersection)) +print("Union completed!") From 845e1d4cfa468e46bfeda92cdacf6be355b59cea Mon Sep 17 00:00:00 2001 From: Roberto Larcher Date: Wed, 6 Mar 2019 10:37:49 +0100 Subject: [PATCH 2/3] adjusted comments for union-gt-and-pred.py --- extra/union-gt-and-pred.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/extra/union-gt-and-pred.py b/extra/union-gt-and-pred.py index a12b66f14..40e39fb12 100644 --- a/extra/union-gt-and-pred.py +++ b/extra/union-gt-and-pred.py @@ -5,9 +5,12 @@ ## This script ensures same number of files in ground-truth and predicted folder. ## When you encounter file not found error, it's usually because you have ## mismatched numbers of ground-truth and predicted files. -## You can use this script to move ground-truth and predicted files that are -## not in the intersection into a backup folder (backup_no_matches_found). -## This will retain only files that have the same name in both folders. +## You can use this script to create missing files as empty file. The rationale +## behind is the following: +## - if a file is missing from the ground truth but is present among the +## predictions it means that we have false positives +## - if a file is missing from the predictions but is present in the ground +## truth it means that we have a false negative # change directory to the one with the files to be changed path_to_gt = '../ground-truth' @@ -28,18 +31,14 @@ pred_files = set(pred_files) print('total ground-truth files:', len(gt_files)) print('total predicted files:', len(pred_files)) -print() gt_backup = gt_files - pred_files pred_backup = pred_files - gt_files -print("gt_backup:", gt_backup) -print("pre_backup:", pred_backup) - def backup(src_folder, backup_files, dst_folder): # non-intersection files (txt format) will be moved to a backup folder if not backup_files: - print('No backup required for', src_folder) + print('No missing file in', dst_folder) return os.chdir(src_folder) ## create the backup dir if it doesn't exist already @@ -49,10 +48,10 @@ def backup(src_folder, backup_files, dst_folder): backup(path_to_gt, gt_backup, path_to_pred) backup(path_to_pred, pred_backup, path_to_gt) if gt_backup: - print('total ground-truth backup files:', len(gt_backup)) + print('total predicted added files:', len(gt_backup)) if pred_backup: - print('total predicted backup files:', len(pred_backup)) + print('total ground-truth added files:', len(pred_backup)) -intersection = gt_files | pred_files -print('total union files:', len(intersection)) +union = gt_files | pred_files +print('total union files:', len(union)) print("Union completed!") From f5257530d758b2fae88fd2c93e3a55f16554cf83 Mon Sep 17 00:00:00 2001 From: Roberto Larcher Date: Wed, 15 May 2019 09:09:31 +0200 Subject: [PATCH 3/3] not showing plot --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 60188f15d..b7c2eb47c 100644 --- a/main.py +++ b/main.py @@ -845,7 +845,7 @@ def draw_plot_func(dictionary, n_classes, window_title, plot_title, x_label, out plot_title = "mAP = {0:.2f}%".format(mAP*100) x_label = "Average Precision" output_path = results_files_path + "/mAP.png" - to_show = True + to_show = False plot_color = 'royalblue' draw_plot_func( ap_dictionary,