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_val(self, sample): val_transforms = list() val_transforms.append(tr.Resize(self.cfg.LOAD_SIZE)) if self.cfg.MULTI_SCALE: val_transforms.append(tr.MultiScale(size=self.cfg.FINE_SIZE,scale_times=self.cfg.MULTI_SCALE_NUM, ms_targets=self.ms_targets)) val_transforms.append(tr.ToTensor()) val_transforms.append(tr.Normalize(mean=self.cfg.MEAN, std=self.cfg.STD, ms_targets=self.ms_targets)) composed_transforms = transforms.Compose(val_transforms)
def transform_val(self, sample): val_transforms = list() val_transforms.append(tr.Resize(self.cfg.LOAD_SIZE)) # val_transforms.append(tr.CenterCrop(self.cfg.FINE_SIZE)) # if self.cfg.MULTI_SCALE: # val_transforms.append(tr.MultiScale(size=self.cfg.FINE_SIZE,scale_times=self.cfg.MULTI_SCALE_NUM, ms_targets=self.ms_targets)) if self.cfg.MULTI_SCALE_TEST:#new add val_transforms.append(tr.MultiScale_Val(self.cfg.LOAD_SIZE,self.cfg.RESIZE_LIST))#new add val_transforms.append(tr.ToTensor()) val_transforms.append(tr.Normalize(mean=self.cfg.MEAN, std=self.cfg.STD, ms_targets=self.ms_targets)) composed_transforms = transforms.Compose(val_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)
def transform_val(self, sample): val_transforms = list() # val_transforms.append(tr.FixScaleCrop(crop_size=self.cfg.FINE_SIZE)) val_transforms.append(tr.Resize(self.cfg.LOAD_SIZE)) # if not self.cfg.SLIDE_WINDOWS: val_transforms.append(tr.CenterCrop(self.cfg.FINE_SIZE)) if self.cfg.MULTI_SCALE_TEST: val_transforms.append( tr.MultiScale_Val(self.cfg.FINE_SIZE, self.cfg.RESIZE_LIST)) val_transforms.append(tr.ToTensor()) val_transforms.append( tr.Normalize(mean=self.cfg.MEAN, std=self.cfg.STD, ms_targets=self.ms_targets)) composed_transforms = transforms.Compose(val_transforms) return composed_transforms(sample)