Multi-channel images are common in the fields of satellite remote sensing (GIS) and in medical imaging. Many of the multispectral satellites I work with in my research have 8+ spectral bands, not just RGB. Some hyperspectral satellites have as many as 136 spectral bands. Microscopy often involves 4+ channel images as well.
Currently, torchvision relies on the Python Imaging Library (PIL) for all of its transforms. Unfortunately, pillow does not support multi-channel images: https://github.com/python-pillow/Pillow/issues/3160, https://github.com/python-pillow/Pillow/issues/1888
The way I see it, researchers such as myself have 3 options:
I'm about to resort to 3 for my research. Do you have any suggestions for users like me?
I agree that is indeed a common problem in remote sensing, especially hyperspectral imaging.
This is an ongoing discussion (although for some other reasons), which leans to option 2. Recently @fmassa stated:
[...] I'd rather not rush things just yet
Thus, if I were you, I would go with option 3. for now, but check back regularly for official support.
I would love for this to be a focus. Not only is it a problem for multi-channel data, but also it causes issue for target transformations for semantic segmentation where a channel is needed for each target.
@jphdotam we are going to be following a slightly different approach for semantic segmentation, where we will be using torch operations to perform the transformations.
See https://github.com/pytorch/vision/blob/master/references/segmentation/transforms.py for an example
By the way, in https://github.com/pytorch/vision/pull/1104 we are slowly going to be starting to support PyTorch Tensors for some of the transforms natively in torchvision, so that this won't be an issue anymore
According to the v0.8.0 release notes, multi-channel images are now natively supported! Thanks so much for everyone's hard work!!!
Thanks @adamjstewart !
Let us know if you find any issues with it
I actually just started a new research project using drone-based hyperspectral imagery (128+ spectral bands), so I'll definitely be testing this feature to the extreme!
Most helpful comment
By the way, in https://github.com/pytorch/vision/pull/1104 we are slowly going to be starting to support PyTorch Tensors for some of the transforms natively in torchvision, so that this won't be an issue anymore