I’m trying to load images using a DataLoader with a specific batch size to feed into a CNN.
mean = torch.tensor([0.5], dtype=torch.float32)
std = torch.tensor([0.5], dtype=torch.float32)

train_transforms = transforms.Compose([transforms.Resize(size=(700, 700)),
                                       transforms.RandomHorizontalFlip(p=0.5),
                                       transforms.RandomPerspective(distortion_scale=0.1, p=1),
                                       transforms.Grayscale(1),
                                       transforms.ToTensor(),
                                       transforms.Normalize(mean, std)]) 

test_transforms = transforms.Compose([transforms.Resize((700, 700)),
                                      transforms.ToTensor(),
                                      transforms.Normalize(mean, std)]) 

train_data = ImageFolder(train_dir, transform=train_transforms)
test_data = ImageFolder(test_dir, transform=test_transforms)

train_loader = DataLoader(train_data, batch_size=64, shuffle=True)
test_loader = DataLoader(test_data, batch_size=32, shuffle=True)

When loading the (images, labels) pair vis next:
data_iter = iter(data_loader)
images, labels = next(data_iter)

I get this error:
UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='./data/train/1. angle-high/._Screen Shot 2020-11-29 at 8.23.59 AM.png'>

Checking for hidden files using command+shift+. in MacOS, I can’t find any hidden files (starting with “._” in the directory).