From 446dfbd4b909f447298752e0ac03ea235771cd98 Mon Sep 17 00:00:00 2001 From: HinGwenWoong Date: Mon, 19 Dec 2022 16:55:33 +0800 Subject: [PATCH] Add raise when class is blank or space between words (#391) --- tools/dataset_converters/labelme2coco.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/dataset_converters/labelme2coco.py b/tools/dataset_converters/labelme2coco.py index 94e46e16..20108b30 100644 --- a/tools/dataset_converters/labelme2coco.py +++ b/tools/dataset_converters/labelme2coco.py @@ -274,7 +274,15 @@ def convert_labelme_to_coco(image_dir: str, assert len(txt_lines) > 0 for txt_line in txt_lines: - v, k = txt_line.split(' ') + class_info = txt_line.split(' ') + if len(class_info) != 2: + raise ValueError('Error parse "class_id_txt" file ' + f'{class_id_txt}, please check if some of ' + 'the class names is blank, like "1 " -> ' + '"1 blank", or class name has space between' + ' words, like "1 Big house" -> "1 ' + 'Big-house".') + v, k = class_info all_classes_id.update({k: v}) else: all_classes_id = None