Based on the error message it looks like (some) images might be grayscale images and thus only contain one channel.
If that’s the case for all images, just use a single value for the mean and std arguments:
transforms.Normalize((0.5,), (0.5,))

Alternatively, if just a few images are gray while others are RGB images, you could convert these images after loading using:
img = Image.open(path).convert('RGB')