Esempio n. 1
0
    def __init__(self, mode, quality='fine', joint_transform_list=None,
                 img_transform=None, label_transform=None, eval_folder=None):

        super(Loader, self).__init__(quality=quality, mode=mode,
                                     joint_transform_list=joint_transform_list,
                                     img_transform=img_transform,
                                     label_transform=label_transform)

        ######################################################################
        # Cityscapes-specific stuff:
        ######################################################################
        self.root = cfg.DATASET.CITYSCAPES_DARK_DIR
        self.id_to_trainid = cityscapes_labels.label2trainid
        self.trainid_to_name = cityscapes_labels.trainId2name
        self.fill_colormap()
        img_ext = 'jpg'
        mask_ext = '.png'
        img_root = path.join(self.root, 'leftImg8bit')
        mask_root = path.join(self.root, 'gtFine')
        if mode == 'folder':
            self.all_imgs = make_dataset_folder(eval_folder)
        else:
            self.fine_cities = cities_cv_split(self.root, mode, cfg.DATASET.CV)
            self.all_imgs = self.find_cityscapes_images(
                self.fine_cities, img_root, mask_root, img_ext, mask_ext)

        logx.msg(f'cn num_classes {self.num_classes}')
        self.fine_centroids = uniform.build_centroids(self.all_imgs,
                                                      self.num_classes,
                                                      self.train,
                                                      cv=cfg.DATASET.CV,
                                                      id2trainid=self.id_to_trainid)
        self.centroids = self.fine_centroids

        if cfg.DATASET.COARSE_BOOST_CLASSES and mode == 'train':
            self.coarse_cities = coarse_cities(self.root)
            img_root = path.join(self.root,
                                 'leftImg8bit_trainextra/leftImg8bit')
            mask_root = path.join(self.root, 'gtCoarse', 'gtCoarse')
            self.coarse_imgs = self.find_cityscapes_images(
                self.coarse_cities, img_root, mask_root, img_ext, mask_ext,
                fine_coarse='gtCoarse')

            if cfg.DATASET.CLASS_UNIFORM_PCT:   
                
                custom_coarse = (cfg.DATASET.CUSTOM_COARSE_PROB is not None)
                self.coarse_centroids = uniform.build_centroids(
                    self.coarse_imgs, self.num_classes, self.train,
                    coarse=(not custom_coarse), custom_coarse=custom_coarse,
                    id2trainid=self.id_to_trainid)

                for cid in cfg.DATASET.COARSE_BOOST_CLASSES:
                    self.centroids[cid].extend(self.coarse_centroids[cid])
            else:
                self.all_imgs.extend(self.coarse_imgs)

        self.build_epoch()
Esempio n. 2
0
    def __init__(self,
                 mode,
                 quality='semantic',
                 joint_transform_list=None,
                 img_transform=None,
                 label_transform=None,
                 eval_folder=None):

        super(Loader, self).__init__(quality=quality,
                                     mode=mode,
                                     joint_transform_list=joint_transform_list,
                                     img_transform=img_transform,
                                     label_transform=label_transform)

        root = cfg.DATASET.CITYSURFACES_DIR
        self.id_to_trainid = label2trainid
        self.trainid_to_name = trainId2name
        self.fill_colormap()

        ######################################################################
        # Assemble image lists
        ######################################################################
        if mode == 'folder':

            img_ext = 'png'
            mask_ext = 'png'
            img_root = os.path.join(root, 'val', 'images')
            mask_root = os.path.join(root, 'val', 'annotations')
            self.all_imgs = self.find_images(img_root, mask_root, img_ext,
                                             mask_ext)
        elif mode == 'test':
            self.all_imgs = make_dataset_folder(eval_folder, test_mode=True)
        else:
            splits = {'train': 'train', 'val': 'val', 'test': 'tests'}
            split_name = splits[mode]
            img_ext = 'png'
            mask_ext = 'png'
            img_root = os.path.join(root, split_name, 'images')
            mask_root = os.path.join(root, split_name, 'annotations')
            self.all_imgs = self.find_images(img_root, mask_root, img_ext,
                                             mask_ext)
        logx.msg('all imgs {}'.format(len(self.all_imgs)))
        self.fine_centroids = uniform.build_centroids(
            self.all_imgs,
            self.num_classes,
            self.train,
            cv=cfg.DATASET.CV,
            id2trainid=self.id_to_trainid)
        self.centroids = self.fine_centroids

        self.build_epoch()
    def __init__(self,
                 mode,
                 quality='semantic',
                 joint_transform_list=None,
                 img_transform=None,
                 label_transform=None,
                 eval_folder=None):

        super(Loader, self).__init__(quality=quality,
                                     mode=mode,
                                     joint_transform_list=joint_transform_list,
                                     img_transform=img_transform,
                                     label_transform=label_transform)

        root = cfg.DATASET.VAIHINGEN_DIR
        self.mode = mode
        self.fill_colormap()
        ######################################################################
        # Assemble image lists
        ######################################################################
        if mode == 'folder':
            self.all_imgs = make_dataset_folder(eval_folder)
        else:
            splits = {
                'train': 'training',
                'val': 'validation',
                'trainval': 'trainval',
                'test': 'testing'
            }
            split_name = splits[mode]
            #img_ext = 'jpg'
            #mask_ext = 'png'
            #img_root = os.path.join(root, split_name, 'images')
            #mask_root = os.path.join(root, split_name, 'labels')
            if mode is 'test':
                self.all_imgs = make_dataset(root, quality, mode)
            else:
                self.all_imgs = make_dataset(root, quality, mode)
        logx.msg('all imgs {}'.format(len(self.all_imgs)))
        self.centroids = uniform.build_centroids(self.all_imgs,
                                                 self.num_classes,
                                                 self.train,
                                                 cv=cfg.DATASET.CV)
        self.build_epoch()
Esempio n. 4
0
    def __init__(self,
                 mode,
                 quality='fine',
                 joint_transform_list=None,
                 img_transform=None,
                 label_transform=None,
                 eval_folder=None):

        super(Loader, self).__init__(quality=quality,
                                     mode=mode,
                                     joint_transform_list=joint_transform_list,
                                     img_transform=img_transform,
                                     label_transform=label_transform)

        root = cfg.DATASET.KITTI_DIR
        ######################################################################
        # Assemble image lists
        ######################################################################
        if mode == 'folder':
            self.all_imgs = make_dataset_folder(eval_folder)
        else:
            splits = {
                'train': 'training',
                'val': 'training',
                'test': 'training'
            }
            split_name = splits[mode]
            img_ext = 'png'
            mask_ext = 'png'
            img_root = os.path.join(root, split_name, 'image_2')
            mask_root = os.path.join(root, split_name, 'semantic_rgb')
            self.all_imgs = self.find_images(img_root, mask_root, img_ext,
                                             mask_ext)

        import ipdb
        ipdb.set_trace()

        self.fill_colormap()
        logx.msg('all imgs {}'.format(len(self.all_imgs)))
        self.centroids = uniform.build_centroids(self.all_imgs,
                                                 self.num_classes,
                                                 self.train,
                                                 cv=cfg.DATASET.CV)
        self.build_epoch()
Esempio n. 5
0
    def __init__(self,
                 mode,
                 quality='semantic',
                 joint_transform_list=None,
                 img_transform=None,
                 label_transform=None,
                 eval_folder=None):

        super(Loader, self).__init__(quality=quality,
                                     mode=mode,
                                     joint_transform_list=joint_transform_list,
                                     img_transform=img_transform,
                                     label_transform=label_transform)

        root = cfg.DATASET.MAPILLARY_DIR
        config_fn = os.path.join(root, 'config.json')
        self.fill_colormap_and_names(config_fn)

        ######################################################################
        # Assemble image lists
        ######################################################################
        if mode == 'folder':
            self.all_imgs = make_dataset_folder(eval_folder)
        else:
            splits = {
                'train': 'training',
                'val': 'validation',
                'test': 'testing'
            }
            split_name = splits[mode]
            img_ext = 'jpg'
            mask_ext = 'png'
            img_root = os.path.join(root, split_name, 'images')
            mask_root = os.path.join(root, split_name, 'labels')
            self.all_imgs = self.find_images(img_root, mask_root, img_ext,
                                             mask_ext)
        logx.msg('all imgs {}'.format(len(self.all_imgs)))
        self.centroids = uniform.build_centroids(self.all_imgs,
                                                 self.num_classes,
                                                 self.train,
                                                 cv=cfg.DATASET.CV)
        self.build_epoch()