fizyr / keras-retinanet

Keras implementation of RetinaNet object detection.
Apache License 2.0
4.38k stars 1.96k forks source link

Grayscale images Instead of RGB #1520

Closed chairiq closed 3 years ago

chairiq commented 3 years ago

What changes have to be done in the code for the use of grayscale images instead of RGB?

babu-akhil commented 3 years ago

Change the model input shape to make it single channel. By default it would be something like (IMAGE_HEIGHT, IMAGE_WIDTH, 3). Change that to (IMAGE_HEIGHT,IMAGE_WIDTH,1).

marqcordova commented 3 years ago

@chairiq This is going to be a problem for you since the code imports a resnet backbone (default = resnet50) model from Tensorflow. TF imports the model with 3 color channels. There's no way to import it with only a single color channel as far as I know. The best thing to do would be to stack your grayscale image 3 times. Go from (IMAGE_HEIGHT,IMAGE_WIDTH,1) and stack them into (IMAGE_HEIGHT,IMAGE_WIDTH,3). It's not a big deal computationally since all of the color channels are combined after the first hidden layer. So with an input image of (IMAGE_HEIGHT,IMAGE_WIDTH,1) you'd only save a little on the first layer.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale due to the lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.