Skip to content

Commit

Permalink
fix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
yasakova-anastasia committed Mar 16, 2021
1 parent dd6eecf commit 68e41dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions datumaro/plugins/camvid_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 68e41dc

Please sign in to comment.