def compute_visuals(self): mid = self.opt.nframes // 2 self.LR = self.LR[:, mid, ...] if self.opt.phase in ("train", "test"): self.HR_GroundTruth = self.HR_GroundTruth[:, mid, ...] if self.opt.phase in ("test", "apply"): # remove pad for LR if self.opt.phase == "test": h, w = self.HR_GroundTruth.shape[ -2], self.HR_GroundTruth.shape[-1] else: # apply h, w = self.HR_GT_h, self.HR_GT_w self.LR = remove_pad_for_tensor(tensor=self.LR, HR_GT_h_w=(h, w), factor=self.SR_factor, LR_flag=True) # remove pad for HR_G self.HR_G = remove_pad_for_tensor(tensor=self.HR_G, HR_GT_h_w=(h, w), factor=self.SR_factor, LR_flag=False) # 将HR_G的边缘部分替换为LR的 两个像素 assert self.LR.shape == self.HR_G.shape # [1,3,H,W] self.HR_G[..., 0:2, :] = self.LR[..., 0:2, :] self.HR_G[..., -2:, :] = self.LR[..., -2:, :] self.HR_G[..., :, 0:2] = self.LR[..., :, 0:2] self.HR_G[..., :, -2:] = self.LR[..., :, -2:]
def compute_visuals(self): mid = self.opt.nframes // 2 self.LR = self.LR[:, mid, ...] if self.opt.phase == "test": # remove pad for LR self.LR = remove_pad_for_tensor( tensor=self.LR, HR_GT_h_w=(self.HR_GroundTruth.shape[-2], self.HR_GroundTruth.shape[-1]), factor=self.SR_factor, LR_flag=True) # remove pad for HR_G self.HR_G = remove_pad_for_tensor( tensor=self.HR_G, HR_GT_h_w=(self.HR_GroundTruth.shape[-2], self.HR_GroundTruth.shape[-1]), factor=self.SR_factor, LR_flag=False) self.HR_Bicubic = torch.nn.functional.interpolate( self.LR, scale_factor=self.SR_factor, mode='bicubic', align_corners=False)