I am using Keras for some DL experiments. After train my model, I would like to test my model with following code :
test_datagen = ImageDataGenerator(rescale=1 / 255.)
test_generator = test_datagen.flow_from_directory(directory='test/',
color_mode='grayscale',
# don't shuffle
shuffle=False,
# use same size as in training
target_size=(256, 256),
batch_size=1,
class_mode=None
)
preds = model.predict_generator(test_generator, steps=12)
The problem is test folder contains also subdirectories inside another subdirectories. (e.g. test/test2/test3/test4 ...) and I would like to reach images inside test4 folder too but I got IsADirectoryError: [Errno 21] Is a directory: 'test/test2/test3'
error.
My first question is: is there any possibility to search and use instead copy and paste all images into one folder?
Second : I want to use only .png formatted images. Can I do something like that? from_directory(directory='test/*.png')
for only .png files?
Thank you in advance. Updated : 24/02/20