This a one of several approaches you can take
Here in the init method you can create a structure which stores paths to all images, any structure that can be indexed.
eg: list of image paths [’/img/1.png’ , ‘/img/2.png’ …]
Then in the getitem method you can load the corresponding image to a index x
(Add parameters to the init function if you want to)
from torch.utils.data import Dataset

class DataClass(Dataset):
    def __init__(self):
        self.list_of_paths = ... # Here create a list of all image paths / paths..

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

    def __getitem__(self, x):
        image_path = self.list_of_paths[x] # Gives the path to an image
        image = load_image ... # Here load your image using your path
        
        return image


then create a ds
train_ds = DataClass()
train_dl = DataLoader(train_ds ...)