From 4cf6723c2883790bed6406ceb95eeed4add73674 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Wed, 10 Jul 2019 12:02:10 +0200 Subject: [PATCH] Added ability to use custom string for debug save of train images Signed-off-by: Jim Martens --- src/twomartens/masterthesis/debug.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/twomartens/masterthesis/debug.py b/src/twomartens/masterthesis/debug.py index 2afd67f..ae5a2da 100644 --- a/src/twomartens/masterthesis/debug.py +++ b/src/twomartens/masterthesis/debug.py @@ -33,7 +33,7 @@ from twomartens.masterthesis import config from twomartens.masterthesis.ssd_keras.eval_utils import coco_utils -def save_ssd_train_images(images: np.ndarray, labels: np.ndarray, output_path: str) -> None: +def save_ssd_train_images(images: np.ndarray, labels: np.ndarray, output_path: str, custom_string: str = None) -> None: annotation_file_train = f"{config.get_property('Paths.coco')}/annotations/instances_train2014.json" _, _, _, classes_to_names = coco_utils.get_coco_category_maps(annotation_file_train) colors = pyplot.cm.hsv(np.linspace(0, 1, 81)).tolist() @@ -42,12 +42,13 @@ def save_ssd_train_images(images: np.ndarray, labels: np.ndarray, output_path: s nr_images = len(images) nr_digits = math.ceil(math.log10(nr_images)) image_size = config.get_property("Parameters.ssd_image_size") + custom_string = f"{custom_string}_" if custom_string is not None else "" for i, train_image in enumerate(images): instances = labels[i] image = Image.fromarray(train_image) image.save(f"{output_path}/" - f"train_image{str(i).zfill(nr_digits)}.png") + f"{custom_string}train_image{str(i).zfill(nr_digits)}.png") figure = pyplot.figure(figsize=(20, 12)) pyplot.imshow(image)