I am creating a classifier using PyTorch for classifying a dog and cat. My question is that I only have 10000 images for cats and dogs, 8000 for training and 2000 for testing. So to prevent overfitting I want to use keras’s ImageDataGenerator function to generator augmented images. This is what I did for that portion
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2, #corresponds to shearing to the images
zoom_range = 0.2, #corresponds to a random zoom on the images
horizontal_flip = True) #flips the images horizontally
test_datagen = ImageDataGenerator(rescale = 1./255) #preprocessing the images of the test set
#since our images are formatted in a certain way we use the flow_from_directory() function
#Creating the training set
training_set = train_datagen.flow_from_directory('dataset/training_set',
target_size = (64, 64),
batch_size = 32,
class_mode = 'binary')
#Creating the test set
test_set = test_datagen.flow_from_directory('dataset/test_set',
target_size = (64, 64),
batch_size = 32,
class_mode ='binary')
Now the only problem is that I need the training_set and test_set to be converted to Torch Variables, but right now there DirectoryIterators. So is there a way to convert the training_set and test_set to Torch Variables. Or can I do the same thing that I did here but using pytorch.
Thank you