New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tensorflow Object Detection API for 1-channel grayscale image #3369
Comments
You could convert a single channel grayscale image to a 3 channel RGB image to use the pre-trained RGB models. Alternatively, you could train a grayscale model yourself by using convert_to_grayscale in models/research/object_detection/protos/image_resizer.proto. |
Hi @mttang, |
Have you figured a workout around for grey scale images @vinay0410 using the object detection api? |
@mttang - how do you convert a single channel grayscale image to an RGB image to use with one of the well known models ? |
@richknight you can use OpenCV's applyColorMap function. I do that to apply the common models on IR image. https://docs.opencv.org/2.4/modules/contrib/doc/facerec/colormaps.html |
Hi @vinay0410,
The expected shape of the tensor is (BATCH_SIZE, WIDTH, HEIGHT, CHANNELS). and you are passing (BATCH_SIZE, WIDTH, HEIGHT) without channel. When you reshape your images you need to keep them as rank-3 images. meaning (480, 640, 1) instead of (480, 640). To do that in numpy:
This changes your rank-2 image of shape 480 x 640 to a rank-3 image of shape 480 x 640 x 1 |
I managed to get it to work with the help of the Stackoverflow community. Take a look: https://stackoverflow.com/questions/51872412/tensorflow-numpy-image-reshape The model is taken from Sentdexs tutorial on Youtube: https://www.youtube.com/watch?v=srPndLNMMpk&list=PLQVvvaa0QuDcNK5GeCQnxYnSSaar2tpku&index=6 |
@vinay0410 how do you solve that error?I'm in stuck with this problem! |
I can't see this working as the expected shape has 3 channels. Anyone tested it? |
img_path = os.path.join(image_subdirectory, data['filename']) encoded_jpg_io = io.BytesIO(encoded_jpg) input image is grayscale image. |
System information
Describe the problem
Is there any way to use pre-trained models in Object Detection API of Tensorflow, which trained for RGB images, for single channel grayscale images(depth) ?
Source code / logs
The text was updated successfully, but these errors were encountered: