diff --git a/datumaro/plugins/camvid_format.py b/datumaro/plugins/camvid_format.py index 28b7631ec2..9df865e686 100644 --- a/datumaro/plugins/camvid_format.py +++ b/datumaro/plugins/camvid_format.py @@ -61,7 +61,7 @@ class CamvidPath: SEGM_DIR = "annot" IMAGE_EXT = '.jpg' MASK_EXT = '.png' - PATTERN = re.compile(r'(.+\.\S+)(?:\s+(.+\.\S+)?)\s*') + PATTERN = re.compile(r'(.+\.\S+)?(?:\s*(.+\.\S+))') def parse_label_map(path): @@ -160,9 +160,11 @@ def _load_items(self, path): items = {} with open(path, encoding='utf-8') as f: for line in f: - search = CamvidPath.PATTERN.search(line.strip('\n')) + search = CamvidPath.PATTERN.search(line.strip()) if search: objects = search.groups() + if not objects[0]: + objects = [objects[1], objects[0]] else: raise Exception("Line %s: invalid path format" % line) image = objects[0]