I am trying to apply Keras for images with more than three spectral channels. I noticed that train_datagen handles images with three channels based on color_mode=’rgb’. Is there any way to increase the number input channels or are there any alternative methods?
img_train_generator = train_datagen.flow_from_directory(
"train/image/",
target_size=(64, 64),
batch_size=batch_size,
class_mode= None,
color_mode='rgb',
shuffle=False)
Advertisement
Answer
You can have 1, 3 or 4 channels. See the docs.
color_mode One of “grayscale”, “rgb”, “rgba”. Default: “rgb”. Whether the images will be converted to have 1, 3, or 4 channels.
An alternative is to use tf.data.Dataset for more control. There are examples in the official documentation.