title: Problem with pytorch dataset.imageFolder with custom dataset in Google Colab
body: <p>I am trying to load a dataset for a classification task using pytorch, this is the code i use:</p>
  <pre><code>data_transforms = {
      'train': transforms.Compose([
          transforms.RandomRotation(2.8),
          transforms.RandomResizedCrop(224),
          transforms.RandomHorizontalFlip(),
          transforms.ToTensor(),
          transforms.Normalize((0.5), (0.5))
      ]),
      'valid': transforms.Compose([
          transforms.Resize(256),
          transforms.CenterCrop(224),
          transforms.ToTensor(),
          transforms.Normalize((0.5), (0.5))
      ])
  }
  print(os.listdir())
  # TODO: Load the datasets with ImageFolder
  image_datasets = {x: datasets.ImageFolder(os.path.join(&quot;/content/drive/MyDrive/DatasetPersonale&quot;, x),
                                            data_transforms[x])
                    for x in ['train', 'valid']}
  # TODO: Using the image datasets and the trainforms, define the dataloaders
  batch_size = 32
  dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=batch_size,
                                               shuffle=True, num_workers=4)
                for x in ['train', 'valid']}
  class_names = image_datasets['train'].classes
  print(class_names)
  dataset_sizes = {x: len(image_datasets[x]) for x in ['train', 'valid']}
  
  
  </code></pre>
  <p>the code worked fine but as my dataset was in grayscale, I needed to convert it to RGB so I used this code:</p>
  <pre><code>
  rootdir = '/content/drive/MyDrive/DatasetPersonale/trainRGB'
  print(&quot;Train&quot;)
  for subdir, dirs, files in os.walk(rootdir):
     for file in files:
          filePath = os.path.join(subdir, file)
          name = os.path.basename(filePath)
          img=Image.open(filePath, mode=&quot;r&quot;)
          print(img.mode)
          if img.mode != &quot;RGB&quot;:
              RGBimg=img.convert(&quot;RGB&quot;)
              RGBimg.save(filePath,format=jpeg)
   
         
  </code></pre>
  <p>now my images are still jpeg, but now they are RGB and not L. the problem is that if I go to rerun the code to load the dataset I get this error</p>
  <pre><code>FileNotFoundError                         Traceback (most recent call last)
  &lt;ipython-input-15-3dace4b0f21b&gt; in &lt;module&gt;()
       19 image_datasets = {x: datasets.ImageFolder(os.path.join(&quot;/content/drive/MyDrive/DatasetPersonale&quot;, x),
       20                                           data_transforms[x])
  ---&gt; 21                   for x in ['trainRGB', 'validRGB']}
       22 
       23 # TODO: Using the image datasets and the trainforms, define the dataloaders
  
  4 frames
  &lt;ipython-input-15-3dace4b0f21b&gt; in &lt;dictcomp&gt;(.0)
       19 image_datasets = {x: datasets.ImageFolder(os.path.join(&quot;/content/drive/MyDrive/DatasetPersonale&quot;, x),
       20                                           data_transforms[x])
  ---&gt; 21                   for x in ['trainRGB', 'validRGB']}
       22 
       23 # TODO: Using the image datasets and the trainforms, define the dataloaders
  
  /usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py in __init__(self, root, transform, target_transform, loader, is_valid_file)
      311                                           transform=transform,
      312                                           target_transform=target_transform,
  --&gt; 313                                           is_valid_file=is_valid_file)
      314         self.imgs = self.samples
  
  /usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py in __init__(self, root, loader, extensions, transform, target_transform, is_valid_file)
      144                                             target_transform=target_transform)
      145         classes, class_to_idx = self.find_classes(self.root)
  --&gt; 146         samples = self.make_dataset(self.root, class_to_idx, extensions, is_valid_file)
      147 
      148         self.loader = loader
  
  /usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py in make_dataset(directory, class_to_idx, extensions, is_valid_file)
      190                 &quot;The class_to_idx parameter cannot be None.&quot;
      191             )
  --&gt; 192         return make_dataset(directory, class_to_idx, extensions=extensions, is_valid_file=is_valid_file)
      193 
      194     def find_classes(self, directory: str) -&gt; Tuple[List[str], Dict[str, int]]:
  
  /usr/local/lib/python3.7/dist-packages/torchvision/datasets/folder.py in make_dataset(directory, class_to_idx, extensions, is_valid_file)
      100         if extensions is not None:
      101             msg += f&quot;Supported extensions are: {', '.join(extensions)}&quot;
  --&gt; 102         raise FileNotFoundError(msg)
      103 
      104     return instances
  
  FileNotFoundError: Found no valid file for the classes .ipynb_checkpoints. Supported extensions are: .jpg, .jpeg, .png, .ppm, .bmp, .pgm, .tif, .tiff, .webp
  </code></pre>
  <p>Does someone know why this error appears? I checked the extension of all the files and they are jpeg.</p>
  <p>Thank you.</p>