Example #1
0
    def validate_config(self):
        ids = [s.id for s in self.train_scenes]
        if len(set(ids)) != len(ids):
            raise ConfigError('All training scene ids must be unique.')

        ids = [s.id for s in self.validation_scenes + self.test_scenes]
        if len(set(ids)) != len(ids):
            raise ConfigError(
                'All validation and test scene ids must be unique.')
Example #2
0
    def setup_data(self):
        """Set the the DataSet and DataLoaders for train, validation, and test sets."""
        cfg = self.cfg
        batch_sz = self.cfg.solver.batch_sz
        num_workers = self.cfg.data.num_workers

        train_ds, valid_ds, test_ds = self.get_datasets()
        if len(train_ds) < batch_sz:
            raise ConfigError(
                'Training dataset has fewer elements than batch size.')
        if len(valid_ds) < batch_sz:
            raise ConfigError(
                'Validation dataset has fewer elements than batch size.')
        if len(test_ds) < batch_sz:
            raise ConfigError(
                'Test dataset has fewer elements than batch size.')

        if cfg.overfit_mode:
            train_ds = Subset(train_ds, range(batch_sz))
            valid_ds = train_ds
            test_ds = train_ds
        elif cfg.test_mode:
            train_ds = Subset(train_ds, range(batch_sz))
            valid_ds = Subset(valid_ds, range(batch_sz))
            test_ds = Subset(test_ds, range(batch_sz))

        if cfg.data.train_sz is not None:
            train_inds = list(range(len(train_ds)))
            random.shuffle(train_inds)
            train_inds = train_inds[0:cfg.data.train_sz]
            train_ds = Subset(train_ds, train_inds)

        collate_fn = self.get_collate_fn()
        train_dl = DataLoader(train_ds,
                              shuffle=True,
                              batch_size=batch_sz,
                              num_workers=num_workers,
                              pin_memory=True,
                              collate_fn=collate_fn)
        valid_dl = DataLoader(valid_ds,
                              shuffle=True,
                              batch_size=batch_sz,
                              num_workers=num_workers,
                              pin_memory=True,
                              collate_fn=collate_fn)
        test_dl = DataLoader(test_ds,
                             shuffle=True,
                             batch_size=batch_sz,
                             num_workers=num_workers,
                             pin_memory=True,
                             collate_fn=collate_fn)

        self.train_ds, self.valid_ds, self.test_ds = (train_ds, valid_ds,
                                                      test_ds)
        self.train_dl, self.valid_dl, self.test_dl = (train_dl, valid_dl,
                                                      test_dl)
    def validate_config(self):
        if len(self.class_names) != len(self.class_colors):
            raise ConfigError('len(class_names) must equal len(class_colors')

        self.validate_nonneg('img_sz')
        self.validate_nonneg('num_workers')
        self.validate_augmentors()
        self.validate_data_format()
Example #4
0
 def validate_config(self):
     ids = [s.id for s in self.get_all_scenes()]
     if len(set(ids)) != len(ids):
         raise ConfigError('All scene ids must be unique.')
Example #5
0
 def validate_config(self):
     if self.sample_prob > 1 or self.sample_prob <= 0:
         raise ConfigError('sample_prob must be <= 1 and > 0')
 def validate_config(self):
     if self.run_tensorboard and not self.log_tensorboard:
         raise ConfigError(
             'Cannot run_tensorboard if log_tensorboard is False')
Example #7
0
 def validate_config(self):
     if self.null_class is not None and self.null_class not in self.names:
         raise ConfigError(
             'The null_class: {} must be in list of class names.'.format(
                 self.null_class))
 def validate_config(self):
     if self.train_chip_sz != self.predict_chip_sz:
         raise ConfigError(
             'train_chip_sz must be equal to predict_chip_sz for chip '
             'classification.')
 def validate_config(self):
     if self.vector_source.has_null_class_bufs():
         raise ConfigError(
             'Setting buffer to None for a class in the vector_source is '
             'not allowed for RasterizedSourceConfig.')
 def validate_config(self):
     if self.vector_source.has_null_class_bufs():
         raise ConfigError(
             'Setting buffer to None for a class in the vector_source is '
             'not allowed for ChipClassificationLabelSourceConfig.')