I had to change


camera_catalogue_training[i] to dataset.labels_frame.Label.iloc[i] in get_weighted_sampler

and image = Image.open(image_name) to image = torch.tensor([len(image_name)]) in __getitem__.

Also, I created fake continuous labels, as the sample target labels had missing values, so that the code wouldn’t work:
Name,Label
5443970_0.jpeg,0
4441645_0.jpeg,0
9705709_0.jpeg,0
9989229_0.jpeg,0
9769189_0.jpeg,0
4445197_0.jpeg,0
4432030_0.jpeg,0
4443722_0.jpeg,2
4515753_0.jpeg,3
5440101_0.jpeg,0
4454669_0.jpeg,1
5424361_0.jpeg,2
4512630_0.jpeg,0
4510856_0.jpeg,0
4469947_0.jpeg,0
4523697_0.jpeg,1
9329894_0.jpeg,0
4514251_0.jpeg,1
4445912_0.jpeg,3

Using these changes, the sampler works:
dataset = CameraCatalogueDataset(path, '/')
sampler = get_weighted_sampler(dataset)

loader = DataLoader(
    dataset,
    sampler=sampler,
    batch_size=8)

for data, target in loader:
    print(data, target)

If you remove the sampler, you’ll see that the batches are imbalanced.