title: ValueError: num_samples should be a positive integer value, but got num_samples=0
body: <p>I have data organized as follows: /dataset/train_or_validation/neg_or_pos_class/images.png
  So, inside train or validation I have 2 folders, 1 for negative and 1 for positive.
  I have the error of the title <code>ValueError: num_samples should be a positive integer value, but got num_samples=0</code> because basically I am inside /dataset/train_or_validation, but then I need to access the folders neg or pos. Images are in this format: MCUCXR_0000_1.png for positive images, while MCUCXR_0000_0.png for negative class. I was thinking to extract all the images from the folders, in order to have /dataset/train_or_validation/images.png, but in this case how I can specify which is the class?
  Or, how can I iterate through the positive/negative folders?
  This is my code:</p>
  <pre><code>&quot;&quot;&quot;Montgomery Shard Descriptor.&quot;&quot;&quot;
  
  import logging
  import os
  from typing import List
  from torchvision.datasets import ImageFolder
  from torch.utils.data import DataLoader
  from pathlib import Path
  
  import numpy as np
  import requests
  
  from openfl.interface.interactive_api.shard_descriptor import ShardDataset
  from openfl.interface.interactive_api.shard_descriptor import ShardDescriptor
  
  from torchvision import transforms
  
  # Compose transformations
  train_transform = transforms.Compose([
    transforms.RandomHorizontalFlip(),
    transforms.RandomVerticalFlip(),
    transforms.Resize((512, 512)),
    transforms.ToTensor(),
  ])
  
  test_transform = transforms.Compose([
    transforms.Resize((512, 512)),
    transforms.ToTensor(),
  ])
  
  logger = logging.getLogger(__name__)
  
  
  class MontgomeryShardDataset(ShardDataset):
      &quot;&quot;&quot;Montgomery Shard dataset class.&quot;&quot;&quot;
  
      def __init__(self, dataset_dir: Path, dataset_type: str,):
          &quot;&quot;&quot;Initialize MontgomeryDataset.&quot;&quot;&quot;
          self.data_type = dataset_type
          self.dataset_dir = dataset_dir
          print(self.dataset_dir)
          self.imgs_path = list(dataset_dir.glob('*.png'))
          
      def __getitem__(self, index: int):
          &quot;&quot;&quot;Return an item by the index.&quot;&quot;&quot;
          img_path = self.imgs_path[index]
          img = Image.open(img_path)
          return img
  
      def __len__(self):
          &quot;&quot;&quot;Return the len of the dataset.&quot;&quot;&quot;
          return len(self.imgs_path)
  
  
  class MontgomeryShardDescriptor(ShardDescriptor):
      &quot;&quot;&quot;Montgomery Shard descriptor class.&quot;&quot;&quot;
  
      def __init__(
              self,
              data_folder: str = 'montgomery_data',
              **kwargs
      ):
          &quot;&quot;&quot;Initialize MontgomeryShardDescriptor.&quot;&quot;&quot;
          #print(&quot;Path at terminal when executing this file&quot;)
          print(os.getcwd() + &quot;\n&quot;)
          #print(self.common_data_folder)
          self.data_folder = data_folder 
          self.dataset_dir = Path.cwd() / data_folder
          trainset, testset = self.get_data()
          print(&quot;IO SONO&quot; + &quot;\n&quot;)
          print(self.dataset_dir)
          self.data_by_type = {
              'train': self.dataset_dir / 'TRAIN',
              'val': self.dataset_dir / 'TEST'
          }
  
      def get_shard_dataset_types(self) -&gt; List[str]:
          &quot;&quot;&quot;Get available shard dataset types.&quot;&quot;&quot;
          return list(self.data_by_type)
  
      def get_dataset(self, dataset_type='train'):
          &quot;&quot;&quot;Return a shard dataset by type.&quot;&quot;&quot;
          print(&quot;Path at terminal when executing this file&quot;)
          print(os.getcwd() + &quot;\n&quot;)
          #os.chdir(&quot;/home/lmancuso/openfl/openfl-tutorials/interactive_api/OPENLAB/envoy&quot;)
          if dataset_type not in self.data_by_type:
              raise Exception(f'Wrong dataset type: {dataset_type}')
          return MontgomeryShardDataset(
              dataset_dir=self.data_by_type[dataset_type],
              dataset_type=dataset_type,
          )
  
      @property
      def sample_shape(self):
          &quot;&quot;&quot;Return the sample shape info.&quot;&quot;&quot;
          return ['3', '512', '512']
  
      @property
      def target_shape(self):
          &quot;&quot;&quot;Return the target shape info.&quot;&quot;&quot;
          return ['3', '512', '512']
  
      @property
      def dataset_description(self) -&gt; str:
          &quot;&quot;&quot;Return the dataset description.&quot;&quot;&quot;
          return (f'Montgomery dataset, shard number')
  
      def get_data(self):
          root_dir = &quot;montgomery_data&quot;
          #train_set = ImageFolder(os.path.join(root_dir, &quot;TRAIN&quot;), transform=train_transform)
          #test_set = ImageFolder(os.path.join(root_dir, &quot;TEST&quot;), transform=test_transform)
          train_set = os.path.join(root_dir, &quot;TRAIN&quot;)
          test_set = os.path.join(root_dir, &quot;TEST&quot;)
  
          print('Montgomery data was loaded!')
          return train_set, test_set
  </code></pre>
  <p>I am using the framework for Federated Learning developed by Intel, OpenFL.
  As you can see I tried also to use ImageFolder because I think it can be useful in this case.</p>
  <p>EDIT with the full traceback:</p>
  <pre><code>new_state[k] = pt.from_numpy(tensor_dict.pop(k)).to(device)
             ERROR    Collaborator failed with error: num_samples should be a positive integer value, but got num_samples=0:                           envoy.py:93
                      Traceback (most recent call last):
                        File &quot;/home/lmancuso/openfl/openfl/component/envoy/envoy.py&quot;, line 91, in run
                          self._run_collaborator()
                        File &quot;/home/lmancuso/openfl/openfl/component/envoy/envoy.py&quot;, line 164, in _run_collaborator
                          col.run()
                        File &quot;/home/lmancuso/openfl/openfl/component/collaborator/collaborator.py&quot;, line 145, in run
                          self.do_task(task, round_number)
                        File &quot;/home/lmancuso/openfl/openfl/component/collaborator/collaborator.py&quot;, line 259, in do_task
                          **kwargs)
                        File &quot;/home/lmancuso/openfl/openfl/federated/task/task_runner.py&quot;, line 117, in collaborator_adapted_task
                          loader = self.data_loader.get_train_loader()
                        File &quot;/tmp/ipykernel_8572/1777129341.py&quot;, line 35, in get_train_loader
                        File &quot;/home/lmancuso/bruno/lib/python3.7/site-packages/torch/utils/data/dataloader.py&quot;, line 262, in __init__
                          sampler = RandomSampler(dataset, generator=generator)  # type: ignore
                        File &quot;/home/lmancuso/bruno/lib/python3.7/site-packages/torch/utils/data/sampler.py&quot;, line 104, in __init__
                          &quot;value, but got num_samples={}&quot;.format(self.num_samples))
                      ValueError: num_samples should be a positive integer value, but got num_samples=0
             INFO     Send WaitExperiment request                                                                                            director_client.py:80
             INFO     WaitExperiment response has received                                                                                   director_client.py:82
  </code></pre>