So at this point, let me just try posting all the code, since I’m still getting the same error with the fixes. Maybe I’m missing some small difference.
# Create custom Dataset class
class CameraCatalogueDataset(Dataset):
    """
    Camera Catalogue dataset.
    """
    def __init__(self, csv_file, data_folder, transform=None):
        """
        Args:
            csv_file (string): Path to the csv file with annotations.
            data_folder (string): Directory with all the images.
            transform (callable, optional): Optional transform to be applied
                on a sample.
        """
        self.labels_frame = pd.read_csv(csv_file)
        self.data_folder = data_folder
        self.transform = transform
        self.labels = self.labels_frame.Label.unique()
        self.label_counts = self.labels_frame.Label.value_counts()
        self.num_classes = len(self.labels)

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

    def __getitem__(self, idx):
        image_name = data_folder / self.labels_frame.iloc[idx, 0]
        image = torch.tensor([len(image_name)])
        image_label = self.labels_frame.iloc[idx, 1]

        if self.transform:
            image = self.transform(image)

        return image, image_label

# Function for getting weighted sampler for sampling Training set
def get_weighted_sampler(dataset):
    sampler = None
    # Create weight array for each training sample
    sorted_label_counts = dataset.label_counts.sort_index()
    label_weights = sum(sorted_label_counts.iloc[:]) / np.array(sorted_label_counts.iloc[:])
    sampling_weights = []
    for i in range(len(dataset)):
        image_label = dataset.labels_frame.Label.iloc[i]
        sampling_weights.append(label_weights[image_label])
    sampler = torch.utils.data.sampler.WeightedRandomSampler(sampling_weights , len(sampling_weights))
    return sampler

# Set up file paths 
data_folder = Path('C:/Users/ckwij/Downloads/camera_catalogue/all_combined/')
training_data = data_folder / 'training_subset.csv'
#validation_data = data_folder / 'validation_subset.csv'
#test_data = data_folder / 'test_subset.csv'

# Set up transform for dataset
image_size = 224
dataset_transform = transforms.Compose([
    transforms.Resize(image_size),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

# Initialize dataset and its splits
camera_catalogue_training = CameraCatalogueDataset(csv_file=training_data, data_folder=data_folder, transform=dataset_transform)
#camera_catalogue_validation = CameraCatalogueDataset(csv_file=validation_data, data_folder=data_folder, transform=dataset_transform)
#camera_catalogue_test = CameraCatalogueDataset(csv_file=test_data, data_folder=data_folder, transform=dataset_transform)

# Create data samplers and loaders
training_sampler = get_weighted_sampler(camera_catalogue_training)

training_loader = DataLoader(camera_catalogue_training, batch_size=8, sampler=training_sampler)
#validation_loader = DataLoader(camera_catalogue_validation, batch_size=8, shuffle=True)
#test_loader = DataLoader(camera_catalogue_test, batch_size=8, shuffle=True)

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