0

I am trying to build a CNN and want to divide my input images into non-overlapping patches and then use it for training.

However, I am unsure how to combine the extraction of patches with the code below. I believe a function like tf.image.extract_patches should do the trick but I am unsure how I can include it in the pipeline. It's important for me to use flow_from_directory as I have organised my dataset accordingly.

train_datagen = ImageDataGenerator(rescale = 1./255)
train_generator = train_datagen.flow_from_directory(train_dir,target_size=(64,64),class_mode='categorical',batch_size=64)

I thought of using extract_patches_2d from scikit but it has two issues :

  1. It gives random overlapping patches
  2. I need to resave all images and again reorganize my dataset (same issue as tf.image.extract_patches unless included in pipeline)
Zain
  • 25
  • 7
  • Can [this](https://stackoverflow.com/questions/64326029/load-tensorflow-images-and-create-patches/64326684#64326684) help you? – Nicolas Gervais Nov 03 '20 at 21:34
  • @NicolasGervais Thanks for the response. But again I am confused how can I integrate it with flow_from_directory so that I won't have to repeat the process of reorganising data as I vary my patch size – Zain Nov 03 '20 at 21:59

0 Answers0