Skip to content

Commit

Permalink
[Datumaro] Add debug output in VOC import (#1662)
Browse files Browse the repository at this point in the history
* Add debug output in VOC import
  • Loading branch information
zhiltsov-max authored Jun 8, 2020
1 parent 696a47b commit 0053411
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions datumaro/datumaro/plugins/voc_format/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ def __init__(self, path):
super().__init__(subset=osp.splitext(osp.basename(path))[0])

self._categories = self._load_categories(self._dataset_dir)
log.debug("Loaded labels: %s", ', '.join("'%s'" % l.name
for l in self._categories[AnnotationType.label].items))

label_color = lambda label_idx: \
self._categories[AnnotationType.mask].colormap.get(label_idx, None)
log.debug("Loaded labels: %s" % ', '.join(
"'%s' %s" % (l.name, ('(%s, %s, %s)' % c) if c else '')
for i, l, c in ((i, l, label_color(i)) for i, l in enumerate(
self._categories[AnnotationType.label].items
))
))
self._items = self._load_subset_list(path)

def categories(self):
Expand Down Expand Up @@ -64,6 +71,7 @@ class VocClassificationExtractor(_VocExtractor):
def __iter__(self):
raw_anns = self._load_annotations()
for item_id in self._items:
log.debug("Reading item '%s'" % item_id)
image = osp.join(self._dataset_dir, VocPath.IMAGES_DIR,
item_id + VocPath.IMAGE_EXT)
anns = self._parse_annotations(raw_anns, item_id)
Expand Down Expand Up @@ -99,6 +107,7 @@ def __iter__(self):
anno_dir = osp.join(self._dataset_dir, VocPath.ANNOTATIONS_DIR)

for item_id in self._items:
log.debug("Reading item '%s'" % item_id)
image = osp.join(self._dataset_dir, VocPath.IMAGES_DIR,
item_id + VocPath.IMAGE_EXT)

Expand Down Expand Up @@ -219,6 +228,7 @@ def __init__(self, path):
class VocSegmentationExtractor(_VocExtractor):
def __iter__(self):
for item_id in self._items:
log.debug("Reading item '%s'" % item_id)
image = osp.join(self._dataset_dir, VocPath.IMAGES_DIR,
item_id + VocPath.IMAGE_EXT)
anns = self._load_annotations(item_id)
Expand Down

0 comments on commit 0053411

Please sign in to comment.