Ejemplo n.º 1
0
    def __init__(self, conf, model, dataset, imgdir=None):
        self.conf = conf
        self.model = model

        if imgdir is None:
            self.imgdir = os.path.join(model.logdir, "images")
        else:
            self.imgdir = imgdir

        if not os.path.exists(self.imgdir):
            os.mkdir(self.imgdir)

        loader = self.model.get_loader()

        assert torch.cuda.device_count() > 0

        self.bs = torch.cuda.device_count()

        self.name = "Test"

        self.display_iter = 10

        class_file = self.model.trainer.loader.dataset.vis_file
        self.vis = visualizer.LocalSegVisualizer(
            class_file, conf=conf['dataset'])

        self.loader = loader.get_data_loader(
            conf['dataset'], split="test",
            batch_size=torch.cuda.device_count(),
            shuffle=False, do_augmentation=False, dataset=dataset)
Ejemplo n.º 2
0
    def __init__(self, conf, model, subsample=None,
                 name='', split=None, imgdir=None, do_augmentation=False):
        self.model = model
        self.conf = conf
        self.name = name
        self.imgdir = imgdir

        self.label_coder = self.model.label_coder

        if split is None:
            split = 'val'

        loader = self.model.get_loader()
        batch_size = conf['training']['batch_size']
        if split == 'val' and batch_size > 8:
            batch_size = 8

        if conf['evaluation']['reduce_val_bs']:
            batch_size = torch.cuda.device_count()

        subsampler = partial(
            sampler.SubSampler, subsample=subsample)

        if subsample is not None:
            self.subsample = subsample
        else:
            self.subsample = 1

        self.loader = loader.get_data_loader(
            conf['dataset'], split=split, batch_size=batch_size,
            sampler=subsampler, do_augmentation=do_augmentation,
            pin_memory=False)

        self.minor_iter = max(
            1, len(self.loader) // conf['evaluation']['num_minor_imgs'])

        class_file = self.loader.dataset.vis_file
        self.vis = visualizer.LocalSegVisualizer(
            class_file, conf=conf['dataset'], label_coder=self.label_coder)
        self.binvis = BinarySegVisualizer()

        self.bs = batch_size

        self.num_step = len(self.loader)
        self.count = range(1, len(self.loader) + 5)

        self.names = None
        self.num_classes = self.loader.dataset.num_classes
        self.ignore_idx = -100

        self.display_iter = max(
            1, len(self.loader) // self.conf['logging']['disp_per_epoch'])

        self.smoother = pyvision.utils.MedianSmoother(20)

        self.threeDFiles = {}
Ejemplo n.º 3
0
    def __init__(self, conf, model, data_file, max_examples=None,
                 name='', split=None, imgdir=None):
        self.model = model
        self.conf = conf
        self.name = name
        self.imgdir = imgdir

        self.imgs_minor = conf['evaluation']['imgs_minor']

        self.label_coder = self.model.label_coder

        if split is None:
            split = 'val'

        loader = self.model.get_loader()
        batch_size = conf['training']['batch_size']
        if split == 'val' and batch_size > 8:
            batch_size = 8

        if split == 'val' and conf['evaluation']['reduce_val_bs']:
            batch_size = conf['training']['num_gpus']

        self.loader = loader.get_data_loader(
            conf['dataset'], split=split, batch_size=batch_size,
            lst_file=data_file, shuffle=False, pin_memory=False)

        class_file = conf['dataset']['vis_file']
        self.vis = visualizer.LocalSegVisualizer(
            class_file, conf=conf['dataset'], label_coder=self.label_coder)
        self.bs = batch_size

        if max_examples is None:
            self.num_step = len(self.loader)
            self.count = range(1, len(self.loader) + 5)
        else:
            max_iter = max_examples // self.bs + 1
            self.count = range(1, max_iter + 1)
            self.num_step = max_iter

        self.names = None
        self.num_classes = self.loader.dataset.num_classes
        self.ignore_idx = -100

        self.display_iter = conf['logging']['display_iter']

        self.smoother = pyvision.utils.MedianSmoother(20)
Ejemplo n.º 4
0
    def __init__(self, conf, model, data_file, max_examples=None,
                 name='', split=None, imgdir=None):
        self.model = model
        self.conf = conf
        self.name = name
        self.imgdir = imgdir

        self.split = split

        self.imgs_minor = conf['evaluation']['imgs_minor']

        self.label_coder = self.model.label_coder

        if split is None:
            split = 'val'

        loader = loader_p4
        batch_size = conf['training']['batch_size']
        if split == 'val' and batch_size > 8:
            batch_size = 8

        if split == 'val' and conf['evaluation']['reduce_val_bs']:
            batch_size = 1

        conf['dataset']['transform']['fix_shape'] = False

        config = conf['dataset']

        # config['val_file'] = 'datasets/camvid3d_p4_one.lst'
        config['val_file'] = 'datasets/camvid_p4_full.lst'
        config['vis_file'] = 'datasets/camvid360_classes.lst'
        config['num_worker'] = 0

        config['ignore_label'] = 0
        config['idx_offset'] = 1
        config['num_classes'] = 308

        self.loader = loader.get_data_loader(
            config, split='val', batch_size=batch_size,
            lst_file=config['val_file'], shuffle=False)

        self.loader.dataset.colour_aug = False
        self.loader.dataset.shape_aug = False

        class_file = conf['dataset']['vis_file']
        self.vis = visualizer.LocalSegVisualizer(
            class_file, conf=conf['dataset'], label_coder=self.label_coder)
        self.bs = batch_size

        if max_examples is None:
            self.num_step = len(self.loader)
            self.count = range(1, len(self.loader) + 5)
        else:
            max_iter = max_examples // self.bs + 1
            self.count = range(1, max_iter + 1)
            self.num_step = max_iter

        self.names = None
        self.num_classes = self.loader.dataset.num_classes
        self.ignore_idx = -100

        self.display_iter = conf['logging']['display_iter']

        self.smoother = pyvision.utils.MedianSmoother(20)