Search code examples
pythonpytorchtorchvision

Dataset not found or corrupted. You can use download=True to download it


Recently I downloaded CelebA dataset from this page. I want to apply some transformations to this data set:

To do it firstly let's define transformations:

from torchvision import transforms
from torchvision.datasets CelebA
celeba_transforms = transforms.Compose([
    transforms.CenterCrop(130),
    transforms.Resize([64, 64]),
    transforms.ToTensor()
    ])

And now execute it:

CelebA(root='img_align_celeba',
       split='train',
       download=False,
       transform=celeba_transforms)

However result of this code is an error:

Dataset not found or corrupted. You can use download=True to download it

Setting download=True is also not working. Could you please help me with applying those transformations to this data set?


Solution

  • Finally I resolved the issue. I'm posting my solution:

    Problem number one

    There is a problem with downloading zip file img_align_celeba.zip due to reaching daily quota. Solution to this problem is simply downloading this file from internet e.g. Kaggle.

    Problem number two

    When using function CelebA function with download=True program will think for a while and then return error mentioned in a question title. Cause of the problem are broken .txt files which I listed below (those files are also downloaded via CelebA function):

    enter image description here

    For correct working of this function you have to download those .txt files directly from internet. I found them here. When you download all of those and replace old ones function CelebA should work without any problems.