How to change input channels
Shaochen7 opened this issue · comments
I want to train five channels at the same time, defaulting to RGB three channels. So how can I modify the input channels?
Hello @Shaochen7, the input channel is defined in backbones, e.g. ResNet
If you need to train a model that can handle 5-channel images, you can modify the first layer as follows:
backbone = resnet.__dict__[backbone_name](
pretrained=pretrained_backbone,
replace_stride_with_dilation=replace_stride_with_dilation)
backbone.conv1 = nn.Conv2d(5, self.conv1.out_channels, ...) #<= insert this line
inplanes = 2048
low_level_planes = 256