For instance, if you load images with PIL, instead of calling Image.open(path) in the getitem method, you can create a dict in the init of the dataset with the Image objects corresponding to your images stored at the corresponding path keys and retrieve them in the getitem method, if it makes sense.