Loading LSUN dataset

I am trying to load the LSUN dataset:

train_set = dset.LSUN ( db_path = … , classes=[‘bedroom_train’, … ], transform = … )
trainloader = DataLoader(train_set, batch_size = 64)
for i, data in enumerate(trainloader):

But I am getting this error:

for i, data in enumerate(trainloader):
File “/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py”, line 190, in next
batch = self.collate_fn([self.dataset[i] for i in indices])
File “/usr/local/lib/python2.7/dist-packages/torchvision/datasets/lsun.py”, line 125, in i, getitem
img, _ = db[index]
File “/usr/local/lib/python2.7/dist-packages/torchvision/datasets/lsun.py”, line 37, in getitem
imgbuf = txn.get(self.keys[index])
IndexError: list index out of range

Any ideas? Thanks.

i’m not entirely sure, but maybe the cache is somehow screwed up. If there are any files generated in your current directory that look like index files for LSUN dataset, try to delete them.

1 Like

Awesome… it fixed the issue for me.