Would anyone be able to tell me if it is possible to read the alpha channel of a png image into a Databunch? I have some code pasted below that I have adapted from Lesson 3. I have the default installation of fastai in conda on a GPU server.
from fastai.vision import *
from fastai.callbacks.hooks import *
from fastai.utils.mem import *
from fastai.metrics import *
from pathlib import PosixPath
There are some previous examples of creating custom classes to help work with 4+ channels How to work with 4+ channel images in fastai_v1 which help to clarify things. In the above example, the author is pulling each channel from a different file and appending those together. Obviously you have different requirements.
If you only want to add the alpha channel, I believe that you can just add a parameter to the constructor.
I haven’t tested this, but give it a whirl and let me know. FWIW, I just traced the ImageList code. Internally, the open method will be called for each image file in your dataset. open calls open_image which calls PIL’s convert method which takes in the convert_mode parameter.
The code is definitely hard to trace on github, so if you’re feeling overwhelmed you aren’t alone