0
votes

According to Keras 2.0 documentation, in relation to the input shape of the images that can be fed to the pretrained inception model:

input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (299, 299, 3) (with 'channels_last' data format) or (3, 299, 299) (with 'channels_first' data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 75. E.g. (150, 150, 3) would be one valid value.

However, I am dealing with grayscale image which are 2D. How I should deal with this situation?

1
Just convert the image to color images having identical R, G and B channels. But don't expect the network to behave well on colored images.Jeffrey

1 Answers

0
votes

You can copy the grayscale image 3 times for a pseudoRGB image

import numpy as np
# img=np.zeros((224,224))

If your image is of shape length 2, only width and height you will first need to add an extra dimension:

img = np.expand_dims(img,-1)

The you repeat this last dimension 3 times:

img = np.repeat(img,3,2)
print(img.shape)
# (224,224,3)