You should use a custom dataset as follows:
class CustomDataset(Dataset):
    def __init__(self, path):
        super(CustomDataset, self).__init__()
        self.data = loadFrom(path)

   def __getitem__(self, index):
        return self.data[index]

   def __len__(self):
        return len(self.data)

So, the time of loading data from the local storage is eliminated.