def transform_tr(self, sample): train_transforms = list() train_transforms.append(tr.Resize(self.cfg.LOAD_SIZE)) train_transforms.append(tr.RandomScale(self.cfg.RANDOM_SCALE_SIZE)) train_transforms.append( tr.RandomCrop(self.cfg.FINE_SIZE, pad_if_needed=True, fill=0)) train_transforms.append(tr.RandomRotate()) train_transforms.append(tr.RandomGaussianBlur()) train_transforms.append(tr.RandomHorizontalFlip()) # if self.cfg.TARGET_MODAL == 'lab': # train_transforms.append(tr.RGB2Lab()) if self.cfg.MULTI_SCALE: for item in self.cfg.MULTI_TARGETS: self.ms_targets.append(item) train_transforms.append( tr.MultiScale(size=self.cfg.FINE_SIZE, scale_times=self.cfg.MULTI_SCALE_NUM, ms_targets=self.ms_targets)) train_transforms.append(tr.ToTensor()) train_transforms.append( tr.Normalize(mean=self.cfg.MEAN, std=self.cfg.STD, ms_targets=self.ms_targets)) composed_transforms = transforms.Compose(train_transforms) return composed_transforms(sample)
def transform_tr(self, sample): train_transforms = list() # train_transforms.append(tr.RandomScale(base_size=self.cfg.LOAD_SIZE, crop_size=self.cfg.FINE_SIZE)) train_transforms.append(tr.RandomScale(self.cfg.RANDOM_SCALE_SIZE)) train_transforms.append(tr.Resize(self.cfg.LOAD_SIZE)) train_transforms.append( tr.RandomCrop(self.cfg.FINE_SIZE, pad_if_needed=True, fill=0)) train_transforms.append(tr.RandomGaussianBlur()) train_transforms.append(tr.RandomHorizontalFlip()) train_transforms.append(tr.ToTensor()) train_transforms.append( tr.Normalize(mean=self.cfg.MEAN, std=self.cfg.STD, ms_targets=self.ms_targets)) composed_transforms = transforms.Compose(train_transforms) return composed_transforms(sample)