Thanks for your help I did that but still  I have a problem. What I want to do is that I have an input image let’s note it as LR, and the target image takes it as HR, I fed the LR image into my model(Super-resolution reconstruction model)and the output of the model is SR image. SR and HR have the same scale and they are larger than LR by scale factor m. As my LR images are large if I directly fed the  LR image into the model I get out of memory, that’s why I want to divide it into the smaller patches and reconstruct its corresponding SR, and then combine them to create the final SR image, the result in this way should be the same as when I directly input whole LR into the model. But after applying fold on SR_Patches, the SR image result is messy. Do you have any suggestions on how can solve this issue?
Thanks.
LR_Image.shape :
torch.Size([3, 702, 1020])
HR_Image.shape :
torch.Size([ 3, 1404, 2040])
scale=2
lr_kernel_size= (351,510)
hr_kernel_size= (702,1020)
lr_stride =lr_kernel_size
hr_stride =hr_kernel_size * scale
fold_params = dict(kernel_size=lr_kernel_size, stride=lr_stride)
unfoldlr = nn.Unfold(**fold_params)
lr_patches=unfoldlr(LR_Image)
lr_patches:
torch.Size([1, 537030, 4])
unfoldhr = nn.Unfold(**dict(kernel_size=hr_kernel_size, stride=hr_stride))
hr_patches = unfoldhr(HR_Image)
hr_patches:
torch.Size([1, 2148120, 4])
sr_patches= self.model(lr_patches, idx_scale)
sr_patches: torch.Size([1, 2148120, 4])
fold = nn.Fold(( 1404, 2040), **dict(kernel_size=hr_kernel_size, stride=hr_stride))
sr = fold(sr_patches)
sr.shape:
torch.Size([1, 3, 1404, 2040])