I feed RGB color images to a neural network implemented with Keras. How can I convert Keras images to another color space (for example, YUV, Lab or some shades of gray)?
I tried with a layer Lambda()but got an error:
model.add(Lambda(lambda x: cv2.cvtColor(x, cv2.COLOR_RGB2LAB), input_shape=(160, 320, 3)))
gave me
TypeError: src is not a numpy array, neither a scalar
I believe the problem is what xis a tensor, and I donβt know how to convert it to what OpenCV accepts.
Even better if I can do it in the GPU. For instance. with Tensorflow, I would use features like tf.image.rgb_to_hsv()and tf.image.rgb_to_grayscale().
Thank!
Fanta source
share