MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / Loader

Class Loader

datasets/mapillary.py:43–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class Loader(BaseLoader):
44 num_classes = 65
45 ignore_label = 65
46 trainid_to_name = {}
47 color_mapping = []
48
49 def __init__(self, mode, quality='semantic', joint_transform_list=None,
50 img_transform=None, label_transform=None, eval_folder=None):
51
52 super(Loader, self).__init__(quality=quality,
53 mode=mode,
54 joint_transform_list=joint_transform_list,
55 img_transform=img_transform,
56 label_transform=label_transform)
57
58 root = cfg.DATASET.MAPILLARY_DIR
59 config_fn = os.path.join(root, 'config.json')
60 self.fill_colormap_and_names(config_fn)
61
62 ######################################################################
63 # Assemble image lists
64 ######################################################################
65 if mode == 'folder':
66 self.all_imgs = make_dataset_folder(eval_folder)
67 else:
68 splits = {'train': 'training',
69 'val': 'validation',
70 'test': 'testing'}
71 split_name = splits[mode]
72 img_ext = 'jpg'
73 mask_ext = 'png'
74 img_root = os.path.join(root, split_name, 'images')
75 mask_root = os.path.join(root, split_name, 'labels')
76 self.all_imgs = self.find_images(img_root, mask_root, img_ext,
77 mask_ext)
78 logx.msg('all imgs {}'.format(len(self.all_imgs)))
79 self.centroids = uniform.build_centroids(self.all_imgs,
80 self.num_classes,
81 self.train,
82 cv=cfg.DATASET.CV)
83 self.build_epoch()
84
85 def fill_colormap_and_names(self, config_fn):
86 """
87 Mapillary code for color map and class names
88
89 Outputs
90 -------
91 self.trainid_to_name
92 self.color_mapping
93 """
94 with open(config_fn) as config_file:
95 config = json.load(config_file)
96 config_labels = config['labels']
97
98 # calculate label color mapping
99 colormap = []
100 self.trainid_to_name = {}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected