1
$\begingroup$

I would like to do Transfer Learning using one of the novel networks such as VGG, ResNet, Inception, etc.

The problem is that my images are grayscale (1 channel) since all the above mentioned models were trained on ImageNet dataset (which consists of RGB images).

One of the solutions is to repeat the image array 3 times to make it 3 channel.

Is this really the only solution for that? Is it a good solution? Are there any other solutions?

$\endgroup$
5
  • 1
    $\begingroup$ Here's an answer to it. stackoverflow.com/questions/45939561/… $\endgroup$ Commented May 4, 2019 at 2:36
  • $\begingroup$ Shubham has already provided with another question's link, but I would also like to add one more method here. You can simply change the input layer to accept the grayscale image and then use the pretrained weights for the hidden layers. $\endgroup$ Commented May 4, 2019 at 5:06
  • 1
    $\begingroup$ Dear Shubham, the link provides the same way that I asked about which is "repeat the image array 3 times to make it 3 channel". $\endgroup$ Commented May 4, 2019 at 13:17
  • $\begingroup$ @thanatoz, could you give more detail? what you mean by "You can simply change the input layer to accept the grayscale image and then use the pretrained weights for the hidden layers.". $\endgroup$ Commented May 4, 2019 at 13:18
  • $\begingroup$ @SoK, Sorry, but this approach does not works. Will need to figure out something else. Throws this error Input 0 is incompatible with layer block1_conv1: $\endgroup$ Commented May 6, 2019 at 6:36

1 Answer 1

-1
$\begingroup$
print(grayscale_batch.shape) # (64, 224, 224) rgb_batch = np.repeat(grayscale_batch[..., np.newaxis], 3, -1) print(rgb_batch.shape) # (64, 224, 224, 3) 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.