I am using Keras data augmentation for both my x_train and my y_train images for an image segmentation task.
For this I am using following code:
data_gen_args = dict(width_shift_range = 0.05)
aug = kp.image.ImageDataGenerator(**data_gen_args)
history = model.fit_generator(aug.flow(x_train, y_train, save_to_dir = augment_save_dir),
steps_per_epoch = len(x_train) / 32, validation_data=(x_val, y_val), epochs=epochs, verbose=1)I would like to be sure that the data augmentation operations are applied to both the images and their labels. For this I would like to save the augmented images, but with my code only the augmented images and not their augmented masks are saved to 'save_to_dir'
How can I save both the images and their labels to visualise them?
I have already tried the example on the Keras Image preprocessing page 'Example of transforming images and masks together' : https://keras.io/preprocessing/image/ without success.
I get the error AttributeError: 'zip' object has no attribute 'shape'.
The code:
P.S. I have already posted a question on stackoverflow: https://stackoverflow.com/questions/59074240/keras-image-preprocessing-flowx-y-save-to-dir-only-saves-the-augmented-x-im but did not get any help yet :(
My full network training code can be found under: https://github.com/Jimmy2027/MLEBE/tree/trying_successive_learning
You can run the image augmenter and fetch the images and labels back directly, see method ImageDataGenerator.apply_transform()N.B. I have not used this class
On Mon, Dec 2, 2019 at 6:05 AM hendrik.klug via Keras-users <keras...@googlegroups.com> wrote:
>
> Hi !
>
> I am using Keras data augmentation for both my x_train and my y_train images for an image segmentation task.
>
>
> For this I am using following code:
>
>
> data_gen_args = dict(width_shift_range = 0.05)
> aug = kp.image.ImageDataGenerator(**data_gen_args)
>
> history = model.fit_generator(aug.flow(x_train, y_train, save_to_dir = augment_save_dir),
> steps_per_epoch = len(x_train) / 32, validation_data=(x_val, y_val), epochs=epochs, verbose=1)
>
>
>
> I would like to be sure that the data augmentation operations are applied to both the images and their labels. For this I would like to save the augmented images, but with my code only the augmented images and not their augmented masks are saved to 'save_to_dir'
>
>
> How can I save both the images and their labels to visualise them?
>
>
> I have already tried the example on the Keras Image preprocessing page 'Example of transforming images and masks together' : https://keras.io/preprocessing/image/ without success.
> I get the error AttributeError: 'zip' object has no attribute 'shape'.
>
> The code:
>
> P.S. I have already posted a question on stackoverflow: https://stackoverflow.com/questions/59074240/keras-image-preprocessing-flowx-y-save-to-dir-only-saves-the-augmented-x-im but did not get any help yet :(
>
>
> My full network training code can be found under: https://github.com/Jimmy2027/MLEBE/tree/trying_successive_learning
>
>
> --
> You received this message because you are subscribed to the Google Groups "Keras-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to keras...@googlegroups.com.