As the title clearly describes, the images in the dataset I use do have 3 color channels despite they are grayscale. So, I used
transforms.Grayscale(num_output_channels=1) transformation in order to reduce the number of color channels to 1, but still the loaded images do have 3 channels.
Here is my implementation:
data_transforms = transforms.Compose([ transforms.Grayscale(num_output_channels=1), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) face_train_dataset = datasets.ImageFolder(root=DEST_PATH_TRAIN, transform=data_transforms) train_loader = DataLoader(face_train_dataset, batch_size=train_batch_size, shuffle=True, num_workers=4)