def get_datagen(self, batch_size, mode='train', view=False): if mode == 'train': augmentors = self.get_train_augmentors(self.train_input_shape, self.train_mask_shape, view) data_files = get_files(self.train_dir, self.data_ext) data_generator = loader.train_generator nr_procs = self.nr_procs_train else: augmentors = self.get_valid_augmentors(self.infer_input_shape, self.infer_mask_shape, view) data_files = get_files(self.valid_dir, self.data_ext) data_generator = loader.valid_generator nr_procs = self.nr_procs_valid # set nr_proc=1 for viewing to ensure clean ctrl-z nr_procs = 1 if view else nr_procs dataset = loader.DatasetSerial(data_files) datagen = data_generator(dataset, shape_aug=augmentors[0], input_aug=augmentors[1], label_aug=augmentors[2], batch_size=batch_size, nr_procs=nr_procs) return datagen
def get_datagen(self, opt, mode='train', view=False): if mode == 'train': augmentors = self.get_train_augmentors( self.train_input_shape, self.train_mask_shape, opt['model_flags']['type_classification'], view) data_files = get_files(opt['train_dir'], self.data_ext) data_generator = loader.train_generator nr_procs = self.nr_procs_train batch_size = opt['train_batch_size'] else: augmentors = self.get_valid_augmentors(self.infer_input_shape, self.infer_mask_shape, view) data_files = get_files(opt['valid_dir'], self.data_ext) data_generator = loader.valid_generator nr_procs = self.nr_procs_valid batch_size = opt['infer_batch_size'] print('TRAINER:GET_DATAGEN - Batch Size: ', batch_size) # set nr_proc=1 for viewing to ensure clean ctrl-z nr_procs = 1 if view else nr_procs dataset = loader.DatasetSerial(data_files) datagen = data_generator(dataset, shape_aug=augmentors[0], input_aug=augmentors[1], label_aug=augmentors[2], batch_size=batch_size, nr_procs=nr_procs) return datagen
def get_datagen(self, batch_size, mode="train", view=False): if mode == "train": augmentors = self.get_train_augmentors(self.train_input_shape, self.train_output_shape, view) data_files = get_files(self.train_dir, self.data_ext) # Different data generators for segmentation and classification if self.model_mode == "seg_gland" or self.model_mode == "seg_nuc": data_generator = loader.train_generator_seg else: data_generator = loader.train_generator_class nr_procs = self.nr_procs_train else: augmentors = self.get_valid_augmentors(self.train_input_shape, self.train_output_shape, view) # Different data generators for segmentation and classification data_files = get_files(self.valid_dir, self.data_ext) if self.model_mode == "seg_gland" or self.model_mode == "seg_nuc": data_generator = loader.valid_generator_seg else: data_generator = loader.valid_generator_class nr_procs = self.nr_procs_valid # set nr_proc=1 for viewing to ensure clean ctrl-z nr_procs = 1 if view else nr_procs dataset = loader.DatasetSerial(data_files) if self.model_mode == "seg_gland" or self.model_mode == "seg_nuc": datagen = data_generator( dataset, shape_aug=augmentors[0], input_aug=augmentors[1], label_aug=augmentors[2], batch_size=batch_size, nr_procs=nr_procs, ) else: datagen = data_generator( dataset, shape_aug=augmentors[0], input_aug=augmentors[1], batch_size=batch_size, nr_procs=nr_procs, ) return datagen