Your DataLoader will return a batch of samples and thus add a batch dimension to it.
The height and width calculation in ext_patches_2d_ovl will thus be wrong:
img_h = imgs.shape[1]  #height of the full image
img_w = imgs.shape[0] #width of the full image

and you might need to change it to index2 and index1.