@ptrblck
I just solved the problem by changing the custom dataset class, but I don’t know why…
Below is my new dataset class
class CustomDataset_test(Dataset):
    def __init__(self, files, labels, augmentation, valid):
        self.files = files
        self.labels = labels
        self.aug = augmentation
        self.valid = valid
        self.data = []
        
        for i in range(len(self.files)):
            sample = {}
            sample['img'] = self.files[i] #Image.open(self.files[i])
            sample['label'] = labels[i]
            sample['fname'] = self.files[i]
            self.data.append(sample)
        
    def __len__(self):
        return len(self.data)

    def __getitem__(self, idx):
        x = self.data[idx]['img']
        y = self.data[idx]['label']
        
        x = Image.open(x)
        x1 = self.aug(x)
        
        return {"img": np.array(x1, dtype='float32'), "labels": y, "original": np.array(x,dtype='uint8'), "fname": str(self.data[idx]['fname'])}   
test_transforms = transforms.Compose([
                    #transforms.Resize(224),
                    transforms.ToTensor(),
                    transforms.Normalize((0.2880, 0.2441, 0.2705),(0.2033, 0.1889, 0.1822))
                    #transforms.Normalize((0.2206, 0.1899, 0.2003), (0.1690, 0.1592, 0.1524))
                    ])

The only difference is that I did not open the image file during initialization, but opened it during getitem function. However, I don’t see the difference. Do you know what is the difference between opening an image file using PIL in init and getitem?
Thank you!