def get_patch(self, lr, hr): scale = self.scale[self.idx_scale] # print("scale:",scale) if self.train: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=self.input_large) if not self.args.no_augment: lr, hr = common.augment(lr, hr) elif not self.benchmark: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=self.input_large) if not self.args.no_augment: lr, hr = common.augment(lr, hr) else: try: ih, iw = lr.shape[:2] except: ih, iw = lr[0]['image'].shape[:2] try: hr = hr[0:ih * scale, 0:iw * scale] except: hr = hr[0]['image'][0:ih * scale, 0:iw * scale] return lr, hr
def get_patch(self, lr, hr, lrr, hq): scale = self.scale[self.idx_scale] multi_scale = len(self.scale) > 1 if self.train: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, multi_scale=multi_scale) lrr, _ = common.get_patch(lrr, lrr, patch_size=self.args.patch_size, scale=scale, multi_scale=multi_scale) hq, _ = common.get_patch(hq, hq, patch_size=self.args.patch_size, scale=scale, multi_scale=multi_scale) if not self.args.no_augment: lr, hr, lrr, hq = common.augment(lr, hr, lrr, hq) else: ih, iw = lr.shape[:2] hr = hr[0:ih, 0:iw] lrr = lrr[0:ih, 0:iw] hq = hq[0:ih, 0:iw] return lr, hr, lrr, hq
def get_patch(self, lr, hr): scale = self.scale[self.idx_scale] if self.train: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=self.input_large) #print(lr.shape) if not self.args.no_augment: lr, hr = common.augment(lr, hr) # print(lr.shape) else: # lr, hr = common.get_patch( # lr, hr, # patch_size=self.args.patch_size, # scale=scale, # multi=(len(self.scale) > 1), # input_large=self.input_large # ) # if not self.args.no_augment: lr, hr = common.augment(lr, hr) ih, iw = lr.shape[:2] hr = hr[0:ih * scale, 0:iw * scale] return lr, hr
def _get_patch_bk(self, lr, hr): LR_size = self.opt['LR_size'] lr, hr = common.get_patch(lr, hr, LR_size, self.scale) lr, hr = common.augment([lr, hr]) return lr, hr
def _get_patch(self, lr, hr): LR_size = self.opt['LR_size'] # random crop and augment lr, hr = common.get_patch(lr, hr, LR_size, self.scale) lr, hr = common.augment([lr, hr]) lr = common.add_noise(lr, self.opt['noise']) return lr, hr
def get_patch(self, lr, hr, ix, iy): """ Returns patches for multiple scales """ scale = self.scale if self.train: patch_size = self.args.patch_size - (self.args.patch_size % 4) lr, hr = common.get_patch( lr, hr, patch_size=patch_size, scale=scale, ix=ix, iy=iy ) if not self.args.no_augment: lr, hr = common.augment(lr, hr) else: ih, iw = lr.shape[:2] ih -= ih % 4 iw -= iw % 4 lr = lr[:ih, :iw] hr = hr[:ih * scale, :iw * scale] return lr, hr
def get_patch(self, lr, labels): data = [] data.append(lr) for label in labels: data.append(label) # LR, HR, labels scale = self.scale[self.idx_scale] if self.n_colors == 4: scale = scale * 2 #print(scale) #print(self.args.test_patch_size) if self.train: data = common.get_patch(*data, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=self.input_large) else: data = common.get_center_patch( *data, patch_size=self.args.test_patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=self.input_large) if self.train and not self.args.no_augment: data = common.augment(*data) #print(data[0].shape) #print(data[1].shape) return data
def _get_patch(self, lr, hr,lr2=None,hr2=None): patch_size = self.args.patch_size scale = self.scale[self.idx_scale] multi_scale = len(self.scale) > 1 if self.train: if (self.args.nmodels == 1): lr, hr = common.get_patch( lr, hr, patch_size, scale, multi_scale=multi_scale ) lr, hr = common.augment([lr, hr]) lr = common.add_noise(lr, self.args.noise) else: lr, hr, lr2, hr2 = common.get_patch_2model( lr, hr, lr2, hr2, patch_size, scale, multi_scale=multi_scale ) else: if (self.args.nmodels == 1): ih, iw = lr.shape[0:2] hr = hr[0:ih * scale, 0:iw * scale] else: ih, iw = lr.shape[0:2] hr = hr[0:ih * scale, 0:iw * scale] hr2 = hr2[0:ih * scale, 0:iw * scale] return lr, hr, lr2, hr2
def _get_patch(self, ): # lr, hr): patch_size = self.args.patch_size scale = self.scale[0] multi_scale = len(self.scale) > 1 batch_size = 1 #min(self.args.batch_size, len(self.remain_idx)) # scale = self.scale[self.idx_scale] # multi_scale = len(self.scale) > 1 idx = self.remain_idx[:batch_size] self.remain_idx = self.remain_idx[batch_size:] lr, hr = self.raw_lr[idx], self.raw_hr[idx] lr = lr.astype(np.float32)[0] hr = hr.astype(np.float32)[0] lr = lr[:, :, ::-1] hr = hr[:, :, ::-1] # lr = lr.transpose(2,0,1) # hr = hr.transpose(2,0,1) if self.train: lr, hr = common.get_patch(lr, hr, patch_size, scale, multi_scale=multi_scale) lr, hr = common.augment([lr, hr]) # lr = common.add_noise(lr, self.args.noise) else: ih, iw = lr.shape[0:2] hr = hr[0:ih * scale, 0:iw * scale] return lr, hr
def get_patch(self, lr, hr, nr): lr, hr, nr = common.get_patch(lr, hr, nr, patch_size=self.opt.patch_size, n_channels=1) lr, hr, nr = common.augment(lr, hr, nr) return lr, hr, nr
def _get_patch(self, lr1, lr2, lr3, hr): LR_size = self.opt['LR_size'] # random crop and augment lr1, lr2, lr3, hr = common.get_patch(lr1, lr2, lr3, hr, LR_size, self.scale) lr1, lr2, lr3, hr = common.augment([lr1, lr2, lr3, hr]) return lr1, lr2, lr3, hr
def _get_patch(self, ir, vis): Label_Size = self.opt['Label_Size'] if self.train: ir, vis = common.get_patch(ir, vis, Label_Size, self.scale) ir, vis = common.augment([ir, vis]) ir = common.add_noise(ir, self.opt['noise']) return ir, vis
def _get_patch(self, lr, hr, scale, patch_size, phase_str): if phase_str == 'train': lr, hr = common.get_patch( lr, hr, patch_size, scale) lr, hr = common.augment([lr, hr], self.opt['use_flip'], self.opt['use_rot']) lr = common.add_noise(lr, self.opt['noise']) else: hr = common.modcrop(hr, scale) return lr, hr
def _get_patch(self, lr, hr, lrpan, pan, msx2=False): LR_size = self.opt['LR_size'] # random crop and augment lr, hr, lrpan, pan = common.get_patch(lr, hr, pan, LR_size, self.scale, lrpan=lrpan, msx2=msx2) lr, hr, lrpan, pan = common.augment([lr, hr, lrpan, pan]) lr = common.add_noise(lr, self.opt['noise']) return lr, hr, lrpan, pan
def _get_patch(self, lr, hr): LR_size = self.opt['LR_size'] # random crop and augment lr, hr = common.get_patch(lr, hr, LR_size, self.scale) # print('shapes again here', lr.shape, hr.shape) lr, hr = common.augment([lr, hr]) # lr = common.add_noise(lr, self.opt['noise']) # print('shapes again', lr.shape, hr.shape) return lr, hr
def _get_patch(self, img, tar_shape, scale, seed): # random crop and augment patch = common.get_patch(img, tar_shape, scale, seed) # print('shapes again here', lr.shape, hr.shape) # lr, hr = common.augment([lr, hr]) # lr = common.add_noise(lr, self.opt['noise']) # print('shapes again', lr.shape, hr.shape) return patch
def _get_patch(self, hr, filter, filename, scale_factor, quality_factor, sigma0, sigma1, blur_flag): patch_size = self.args.patch_size # scale = self.scale[self.idx_scale] # multi_scale = len(self.scale) > 1 if self.train: sigma, lr, hr = common.get_patch( hr, patch_size, filename, filter, scale_factor, quality_factor, sigma0, sigma1, blur_flag ) # sigma, lr, hr = common.augment([sigma, lr, hr]) return sigma, lr, hr
def _get_patch(self, lr, hr): LR_size = self.opt['LR_size'] if self.train: lr, hr = common.get_patch( lr, hr, LR_size, self.scale) lr, hr = common.augment([lr, hr]) lr = common.add_noise(lr, self.opt['noise']) else: hr = common.modcrop(hr, self.scale) return lr, hr
def _get_patch(self, img_in, img_tar): patch_size = self.opt.patch_size scale = self.scale if self.train: img_in, img_tar = common.get_patch( img_in, img_tar, patch_size=patch_size, scale=scale) img_in, img_tar = common.augment(img_in, img_tar) else: ih, iw = img_in.shape[:2] img_tar = img_tar[0:ih * scale, 0:iw * scale, :] return img_in, img_tar
def get_patch(self, lr, hr): scale = self.scale[0] if self.train: lr, hr = common.get_patch( lr, hr, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), ) if not self.args.no_augment: lr, hr = common.augment(lr, hr) return lr, hr
def get_patch(self, lr, hr): scale = self.scale[self.idx_scale] if self.train: hr, lr = common.get_patch(hr, lr, patch_size=self.args.patch_size, scale=scale, multi=(len(self.scale) > 1), input_large=True) if self.args.no_augment: lr, hr = common.augment(lr, hr) return lr, hr
def _get_patch(self, img_input, img_tar): patch_size = self.args.patch_size scale = self.scale if self.train: img_input, img_tar = common.get_patch(img_input, img_tar, patch_size, scale) img_input, img_tar = common.augment([img_input, img_tar]) img_input = common.add_noise(img_input, self.sigma) else: ih, iw = img_input.shape[0:2] img_tar = img_tar[0:ih * scale, 0:iw * scale] return img_input, img_tar
def _get_patch(self, img_in, img_tar): scale = self.scale[self.idx_scale] if self.train: img_in, img_tar, pi = common.get_patch( img_in, img_tar, self.args, scale) img_in, img_tar, ai = common.augment(img_in, img_tar) return img_in, img_tar, pi, ai else: ih, iw, c = img_in.shape img_tar = img_tar[0:ih * scale, 0:iw * scale, :] return img_in, img_tar, None, None
def get_patch(self, lr, hr): scale = 1 if self.mode == 'train': lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, n_channels=self.n_channels) if self.args.augment: lr, hr = common.augment(lr, hr) else: ih, iw = lr.shape[:2] hr = hr[0:ih * scale, 0:iw * scale] return lr, hr
def get_patch(self, lr, hr): if self.train: lr, hr = common.get_patch(lr, hr, patch_size=args.input_size, scale=args.scale, input_large=True) lr, hr = common.augment(lr, hr) # 直接实现图像增强 else: ih, iw = lr.shape[:2] hr = hr[0:ih * args.scale, 0:iw * args.scale] return lr, hr
def get_patch(self, lr, hr): scale = self.scale[self.idx_scale] # if self.args.feature_map: # return lr, hr if self.train: lr, hr = common.get_patch(lr, hr, self.args.patch_size, scale, (len(self.scale) > 1)) if not self.args.no_augment: lr, hr = common.augment(lr, hr) else: ih, iw = lr.shape[:2] hr = hr[0:ih * scale, 0:iw * scale] return lr, hr
def get_patch(self, lr, hr): if self.train: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=1, multi=(len(self.scale) > 1), input_large=self.input_large) if not self.args.no_augment: lr, hr = common.augment(lr, hr) else: ih, iw = lr.shape[:2] hr = hr[0:ih, 0:iw] return lr, hr
def get_patch(self, lr, hr): scale = self.scale[self.idx_scale] scale2 = self.scale2[self.idx_scale] if self.train: if self.args.asymm: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, scale2=scale2) else: lr, hr = common.get_patch(lr, hr, patch_size=self.args.patch_size, scale=scale, scale2=scale) if not self.args.no_augment: lr, hr = common.augment(lr, hr) else: ih, iw = lr.shape[:2] hr = hr[0:int(ih * scale), 0:int(iw * scale2)] return lr, hr
def get_patch(self, blur, sharp): if self.train: blur, sharp = common.get_patch( blur, sharp, patch_size=self.args.patch_size, ) if not self.args.no_augment: blur, sharp = common.augment(blur, sharp) else: ih, iw = blur.shape[:2] blur = blur[:ih, :iw] sharp = sharp[:ih, :iw] return blur, sharp
def _get_patch(self, lr, hr): patch_size = self.args.patch_size scale = self.noise_g[self.idx_scale] multi_scale = len(self.noise_g) > 1 if self.train: lr, hr = common.get_patch( lr, hr, patch_size, scale, multi_scale=multi_scale ) lr, hr = common.augment([lr, hr]) lr = common.add_noise(lr, self.args.noise) else: ih, iw = lr.shape[0:2] hr = hr[0:ih * scale, 0:iw * scale] return lr, hr