How to modify Deeplabv3 and FCN models for grayscale images

Hi All,

How can I modify the deeplabv3_resnet101 and fcn_resnet101 models available from torchvision segmentation models to accept input images with only 1 color channel?

I have seen some example of how I can modify resnet, but I am not sure how to do it for these

Thanks
Nishanth

You could replace the first conv layer in a similar manner as done with resnet:

model = torchvision.models.segmentation.deeplabv3_resnet101()
model.backbone.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
x = torch.randn(2, 1, 224, 224)
output = model(x)
2 Likes