I am using keras for an image recognition Sequential CNN model. I have about 300,000 images 424×424, but only the inner 168×168 is relevant.
I am currently using the following code to load the images before training the model, but this just resizes to 168×168 instead of cropping:
from keras.utils import image_dataset_from_directory
train_ds = image_dataset_from_directory(
train_dir,
validation_split=0.2,
subset='training',
color_mode='grayscale',
seed=12345,
image_size = (168,168),
batch_size=64
)
Is there an easy way to crop out the central 168×168 from train_ds?
I know I can crop the original files easily, but I was hoping there was a way to crop within the code, so I can play around with different sizes easily.