I’ve changed the number of input channels in DeepLabV3, because I have NRGB image (N=NIR=Near infrared), the next step is I have to duplicate the weights for the Red channel to make the model be fully pre-trained.
Any ideas ?
import torch
import torch.nn as nn

class MyDeepLab(nn.Module):

    def __init__(self, in_channels=1):
        super(MyDeepLab, self).__init__()
        self.model = torch.hub.load('pytorch/vision:v0.5.0', 'deeplabv3_resnet101', pretrained=True)
        self.model.backbone.conv1 = nn.Conv2d(4, 64, kernel_size=3, stride=2, padding=1, bias=False)

    def forward(self, x):
        return self.model(x)


my_deeplab = MyDeepLab()
print(my_deeplab.state_dict())