How to load gray image in torch vision. I find that folder.py only open image as RGB format:
return Image.open(path).convert('RGB')
I think it should still open a grayscale image, and then convert it to RGB. You could just slice only the first slice along the channel dimension and give that to your network. But we should support that, so I'm leaving the issue open.
But the user can provide it's own loader function, so the user could provide his specific loader that only loads grayscale images.
Is this something we still want to support? I think this can be achieved by either a custom loader or a transform i.e. PIL.ImageOps.grayscale
I had a quick look, it's actually quite difficult to determine if an image is grayscale with PIL (in an efficient manner). If the image is saved correctly as a grayscale single-channel image, PIL will have a mode L, but if the image is saved as RGB with each channel replicated, it will display correctly and PIL will load it with mode RGB.
Given that the user can provide its own loader, or could use a transform to perform the conversion, I think it's better to close this issue. Feel free to comment if you think it should be reopened
Most helpful comment
But the user can provide it's own
loaderfunction, so the user could provide his specific loader that only loads grayscale images.