Ok, I see. Since you have sorted your images in a nice way, let’s just use some internal functions from torchvision.
Here 19 you can see some methods which are used to collect all images and create the targets for them.
Let’s just use these instead of rewriting the code:
root = '[YOURPATH]/Bmp'
classes, class_to_idx = torchvision.datasets.folder.find_classes(dir=root)
imgs = torchvision.datasets.folder.make_dataset(root, class_to_idx)
path, target = imgs[0]

imgs is a list of tuples storing an image path with its target.
You can add these lines to your __init__ method of the Dataset and store imgs as a member.
In the __getitem__ function you could call path, target = self.imgs[index] to get the current sample.
Hope that helps!