ImageBlock(cls=PILImageBW) is creating 3 channel image

I have created datablock with cls=PILImageBW, in the summary I also see it is create PILImage with mode = L , only problem is that, when I am trying to see the shape

binary = DataBlock(blocks=(ImageBlock(cls=PILImageBW), MaskBlock(codes)),

               item_tfms=RandomResizedCrop(460, min_scale=0.5),
               batch_tfms=[*aug_transforms(size=256, min_scale=0.75),

x, y = dls.one_batch()
The shape seems to have 3 channels
torch.Size([8, 3, 256, 256]), torch.Size([8, 256, 256]))

May be some context why I wanted to have 1 channel image, The final model will be converted to onnx model. So I want to have one channel image, otherwise there will be some complexity on the developement side expected. Please let me know whether my problem description is understandable

The standard pre-training image models are all 3 channels since they are derived from training color ImageNet images. So any pre-trained model (based off color ImageNet data) you get will be 3 channels.

1 Like