How to load gray images and keep its size

When i load myself datasets(some gray images, size 512512, format:pgm), i use datasets.ImageFolder, but i found the size of data changed from 512512 to 3512512, it seems that ImageFolder change the signal-channel picture to RGB? How can I load my datasets correctly?

You could use the Dataset class and implement your own loading logic (loading grayscale images) in getitem.

1 Like