Thanks, that post was very helpful. I’m still a little confused about how I should be feeding the patches into my model for prediction and putting the predictions back together.
x = torch.randn(1, 500, 500)  # batch, c, h, w
k = 160 # kernel size
d = 160# stride
patches = x.unfold(1, k, d).unfold(2, k, d)
unfold_shape = patches.size()
patches = patches.contiguous().view(-1, 1,k, k) #my model takes tensors of shape (1,1,160,160)
print(patches.shape)
data = torch.utils.data.DataLoader(patches,batch_size=2,num_workers=0)
for batch in data:
   output = model(batch)
#collect outputs
#fold