do you have Pillow installed and not PIL? That’s one thing I could think of.
Other than that, have a look at https://github.com/pytorch/vision/blob/master/torchvision/datasets/lsun.py#L32-L49 181 which might help.