-
Notifications
You must be signed in to change notification settings - Fork 443
[BUG] Seed should be passed to image_data_generator.get_random_transform #297
Comments
Hello! I see that we set the seed here: https://github.com/keras-team/keras-preprocessing/blob/master/keras_preprocessing/image/iterator.py#L58 COuld you share an example reproducing your issue? |
I use U-Net to perform image segmentation. def generator(batch_size, train_path, image_folder, mask_folder, aug_dict, image_color_mode="grayscale",
mask_color_mode="grayscale", image_save_prefix="image", mask_save_prefix="mask", save_to_dir=None,
target_size=(256, 256), seed=1):
image_datagen = ImageDataGenerator(**aug_dict)
mask_datagen = ImageDataGenerator(**aug_dict)
image_generator = image_datagen.flow_from_directory(
train_path,
classes=[image_folder],
class_mode=None,
color_mode=image_color_mode,
target_size=target_size,
batch_size=batch_size,
save_to_dir=save_to_dir,
save_prefix=image_save_prefix,
seed=seed)
mask_generator = mask_datagen.flow_from_directory(
train_path,
classes=[mask_folder],
class_mode=None,
color_mode=mask_color_mode,
target_size=target_size,
batch_size=batch_size,
save_to_dir=save_to_dir,
save_prefix=mask_save_prefix,
seed=seed)
train_generator = zip(image_generator, mask_generator)
for (img, mask) in train_generator:
img, mask = adjustData(img, mask)
yield (img, mask) |
Hello,
|
Your snipped looks and works fine. But I don't know why I am receiving inconsistently transformed images when comparing saved agumented images from both generators |
I had the same issue using Keras for R and an older version of TF. I just found out that using brightness_range in the image_data_generator was causing the problem. using a preprocessing_function and image_modulate from magick to deal with the brightness solved the problem for me. |
Seed should be passed to this function. In situation when we want to perform the same agumentation for two Image generators this leads to agumentation inconsistency
It should be like this:
params = self.image_data_generator.get_random_transform(x.shape, self.seed)
Instead of
params = self.image_data_generator.get_random_transform(x.shape)
The text was updated successfully, but these errors were encountered: