A preprocessing_function with parameters for ImageDataGenerator
See original GitHub issueHi, I’m training a semantic segmentation keras model on the COCO data-set. I want to create a custom preprocessing function that resets irrelevant objects to zero in the mask image, e.g. I want to train segmentation training and I only care of correctly segmenting ‘cars’, so I want to set to zero all other labels:
The preprocessing function:
def preprocess_mask(x, label):
x = x.astype('int16')
x[x!=label] = 0
return x
The desired generator:
datagen = ImageDataGenerator(
preprocessing_function = preprocess_mask(label=4),
rescale=1./255,
horizontal_flip=True)
But it doesn’t work
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
tf.keras.preprocessing.image.ImageDataGenerator - TensorFlow
Generate batches of tensor image data with real-time data augmentation.
Read more >Custom Preprocessing Function with ImageDataGenerator
In this code snippet, I will show you, how to write a custom preprocessing function to use with ImageDataGenerator to extract image patches,...
Read more >Extending the ImageDataGenerator in Keras and TensorFlow
This article is a tutorial on extending the ImageDataGenerator in Keras and TensorFlow using the preprocessing function.
Read more >Custom Data Augmentation in Keras - Step Up AI
Implement your own custom preprocessing function for data ... extend ImageDataGenerator and specify our own augmentation parameters in the ...
Read more >tf.keras - How to change pre_processing function execution ...
Keras team members said that the ImageDataGenerator class is legacy. They suggest me to use transformation layers.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to implement a Functor in this case.
What if I want to apply a different preprocessing function to each split? Ie. Augmentation on Train split but not on validation split?