You can get a list of files using os.listdir. Then, you can write a custom dataloader like this:
class data_gen(torch.utils.data.Dataset):
    def __init__(self, files):
        
        self.files = files
        
    def __getitem__(self, I):

        #read the images here, convert to torch format and return


    def __len__(self): 
        
        return <number of images>

Then, use an instance like train_dl = data_gen(image_files) and finally use
train_loader = torch.utils.data.DataLoader(
        train_dl, batch_size= , shuffle=True, num_workers= , pin_memory=True)