I have noticed there is a preprocess_input
function that is different according to the model you wanna use in tensorflow.keras.applications
.
I am using ImageDataGenerator
class to augment my data. More specificaly, I am using a CustomDataGenerator
, that extend from the ImageDataGenerator
class and adds a color transformation.
This is how it looks like:
class CustomDataGenerator(ImageDataGenerator):
def __init__(self, color=False, **kwargs):
super().__init__(preprocessing_function=self.augment_color, **kwargs)
self.hue = None
if color:
self.hue = random.random()
def augment_color(self, img):
if not self.hue or random.random() < 1/3:
return img
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
img_hsv[:, :, 0] = self.hue
return cv2.cvtColor(img_hsv, cv2.COLOR_HSV2BGR)
I was using rescale=1./255
on the ImageDataGenerator
, but some models need different preprocessing.
So when I try
CustomDataGenerator(preprocessing_function=tf.keras.applications.xception.preprocess_input)
I get this error:
__init__() got multiple values for keyword argument 'preprocessing_function'