title: How could subset image data
body: <p>I'm working on an image classification problem; the dataset I use is food-101. The data contains 101 classes for each class with 1000 images; how can I feed less images to the model?</p>
  <p>here is a code for splitting the data into train and test</p>
  <pre><code>from shutil import copy
  def prepare_data(filepath, src,dest):
    classes_images = defaultdict(list)
    with open(filepath, 'r') as txt:
        paths = [read.strip() for read in txt.readlines()]
        for p in paths:
          food = p.split('/')
          classes_images[food[0]].append(food[1] + '.jpg')
  
    for food in classes_images.keys():
      print(&quot;\nCopying images into &quot;,food)
      if not os.path.exists(os.path.join(dest,food)):
        os.makedirs(os.path.join(dest,food))
      for i in classes_images[food]:
        copy(os.path.join(src,food,i), os.path.join(dest,food,i))
    print(&quot;Copying Done!&quot;)
  </code></pre>
  <p>then Prepare the training dataset by copying images from food-101/images to food-101/train using the file train.txt</p>
  <pre><code>print(&quot;Creating train data...&quot;)
  prepare_data('food-101/meta/train.txt', 'food-101/images', 'food-101/train')
  
  
  print(&quot;Creating train data...&quot;)
  prepare_data('food-101/meta/train.txt', 'food-101/images', 'food-101/train')
  </code></pre>
  <p>here is the code that will check how many files are in the train folder</p>
  <pre><code>train_files = sum([len(files) for i, j, files in os.walk(&quot;food-101/train/&quot;)])
  print(&quot;Total number of samples in train folder&quot;)
  print(train_files)
  </code></pre>
  <p>will return 75750; this num represents 1000 images from 101 classes. How can I pick 100 images instead 1000 from each classes ?</p>