RuntimeError: Found 0 files in subfolders of: /home/akb/pytorch_learning/dogsandcats/all/train/ Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif

for t in [‘train’,‘valid’]:
for folder in [‘dog/’,‘cat/’]:

    for i in shuffle[:2000]:
        folder = files[i].split('/')[-1].split('.')[0]
        image = files[i].split('/')[-1]

for i in shuffle[2000:]:
folder = files[i].split(’/’)[-1].split(’.’)[0]
image = files[i].split(’/’)[-1]

if torch.cuda.is_available():
is_cuda = True

transforms.Normalize([0.485, 0.456,
0.406,],[0.229, 0.224, 0.225])])

train = ImageFolder(’/home/akb/pytorch_learning/dogsandcats/all/train/’,simple_transform)
valid = ImageFolder(’/home/akb/pytorch_learning/dogsandcats/all/valid/’,simple_transform)

i am working on kaggle dogs vs cats data sets. but getting this error, can anyone help me out. thanks in advance

Could you just validate the paths in your terminal with:

ls /home/akb/pytorch_learning/dogsandcats/all/train/
ls /home/akb/pytorch_learning/dogsandcats/all/valid/

have images in Train folder
no images in valid folder

Similar problem is happening to me when
I used directory processed_celeba/ when loading images from folder.

but surprisingly , when i used the original celeba dataset and unzipped in same folder as directory as

- processed_celeba/
      - celeba

It works finely,

but when i used my own celebrity dataset images and stored in processed_celeba/celeba/
Started throwing error as above.
Thanks for help :slight_smile: .

def get_dataloader(batch_size, image_size, data_dir='processed_celeba_small/'):
    transformed = transforms.Compose([
    data = datasets.ImageFolder(data_dir, transform=transformed)  
    dataloader =, batch_size=batch_size,  shuffle=True, num_workers=0)
    return dataloader

Based on your description you’ve stored your images in processed_celeba/celeba while you are passing processed_celeba_small as the path to the ImageFolder.
I’m not sure if it is just a copy-paste error, but you should provide the same path.

1 Like

@ptrblck ,Sorry but I found it was my silly mistake. It was not accepting my images but accepting that unzipped images.
After debugging, I found that there is no extensions in my images.
processed_celeba_small/ worked well after adding .jpg ext inside to images.