Hi, 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
You need to implement a Functor in this case.
class MyFunctor():
def __init__(self, label):
self.label = label
def __call__(self, x):
...
Do you then pass an instance or the schema?
Edit:
Bad question, an instance.
Most helpful comment
You need to implement a Functor in this case.