Solved by Gul_Zain in post #4 
              
              
                Okay. So all the problems above mentioned are solved by implementing len(self) function in the dataloader. My final dataloader is this. 
class HRFDataset(Dataset):
    def __init__(self, image_paths, target_paths, train=True):
        self.image_paths = image_paths
        self.target_paths = target…