Load Tiff images to dataset


I have a dataset consisting of tiff images (.tiff extension). How do I load it to a pytorch dataset (seeing as torchvision datasets don’t seem to accept this extension)?

Thank you,

As a stop-gap method at least, I have converted all the images to .bmp format using imagemagick (in Ubuntu). I do not know whether this will affect performance, or how much of an effect it will have, but at least the dataset is now being loaded to pytorch.

Looking at torchvision.datasets.ImageFolder code here it seems like
tiff is not supported. This seems like a small bug, since PIL.Image loads tiff without problems?

You can always copy the source I just linked and add tiff extension to IMG_EXTENSIONS, it should then work without issues?

As a hacky workaround:

ls /tmp/test/images/
foo.png  foo.tiff
from torchvision.datasets import ImageFolder
from torchvision.datasets.folder import IMG_EXTENSIONS

len(ImageFolder("/tmp/test/"))  # prints 1


len(ImageFolder("/tmp/test/"))  # prints 2