I was attempting to use my modification of the example code in the Keras documentation that shows how to set up image_datagen.flow_from_directory() in the case where image masks are being used in place of labels (for image segmentation, where we are predicting a class for each pixel).
By the way, I set featurewise_center = True in an attempt to subtract the mean of each color channel of all the training images from each image's color channels, so that over the entire training set, each color channel mean would be 0. I expect this isn't the way to accomplish this.
Anyway, here's my code that generated the error:
image_datagen = ImageDataGenerator(featurewise_center = True)
mask_datagen = ImageDataGenerator()
image_generator = image_datagen.flow_from_directory(
'/home/icg/Martin/train_data_graz/images_rect_r640x360',
class_mode = None,
batch_size = 1,
seed = 123)
mask_generator = mask_datagen.flow_from_directory(
'/home/icg/Martin/train_data_graz/labels_rect_r640x360',
class_mode = None,
batch_size = 1,
seed = 123)
# combine generators into one which yields image and masks
train_generator = zip(image_generator, mask_generator)
model.fit_generator(
train_generator,
steps_per_epoch = 1000,
epochs = 100)
And here's the error message:
Found 0 images belonging to 0 classes.
Found 0 images belonging to 0 classes.
Traceback (most recent call last):
File "FCN_VGG16.py", line 178, in <module>
train_generator = zip(image_generator, mask_generator)
File "/home/icg/rafa/local/lib/python2.7/site-packages/keras/preprocessing/image.py", line 1026, in next
index_array, current_index, current_batch_size = next(self.index_generator)
File "/home/icg/rafa/local/lib/python2.7/site-packages/keras/preprocessing/image.py", line 720, in _flow_index
current_index = (self.batch_index * batch_size) % n
ZeroDivisionError: integer division or modulo by zero
For some reason n = 0. Any ideas why this might happen?