PyTorch-Encoding icon indicating copy to clipboard operation
PyTorch-Encoding copied to clipboard

Changing the number of input channels for segmentation.

Open npielawski opened this issue 4 years ago • 5 comments

Hello Hang Zhang!

Thanks for this nice repo!

I would like to try using DeepLabV3 with ResNeSt in a unconventional way: I am doing pixel regression (regression on images) and my input image only has one channel. I then have to retrain the full model.

I looked into the code, and there is no argument for the input channels, and the pretrained is set to True. I'd like to branch, but I am scared that I will be behind master after some time.

What can we do about this? Do you think it is going to work without using a pretrained backbone? If yes, would you be opened to a pull request adding the possibility to change the number of input channels with an optional argument (I would add the feature to all backbones)?

Thanks in advance!

Best, Nicolas

npielawski avatar Nov 07 '20 15:11 npielawski

Hi,

The input channels are usually defined in the backbone. For example, ResNet's input channel is defined here https://github.com/zhanghang1989/PyTorch-Encoding/blob/master/encoding/models/backbone/resnet.py#L171. If you would like to change it to one channel, you may create your own backbone.

zhanghang1989 avatar Nov 07 '20 18:11 zhanghang1989

Thanks for you input!

I will then create a local backbone then, copying the ResNest arch. I won't be lagging behind master, good idea!

npielawski avatar Nov 07 '20 18:11 npielawski

I looked into using DeepLabV3, but I can only use registered backbones [1], and BaseNet also forces pretrained=True [2] (and I don't have a pretrained model). I could bypass pretrained=True, but I am not too happy with that option.

What would you suggest? Should I also reimplement DeepLabV3 and BaseNet?

[1] https://github.com/zhanghang1989/PyTorch-Encoding/blob/ced288d6fa10d4780fa5205a2f239c84022e71a3/encoding/models/sseg/base.py#L25 [2] https://github.com/zhanghang1989/PyTorch-Encoding/blob/ced288d6fa10d4780fa5205a2f239c84022e71a3/encoding/models/sseg/base.py#L69

npielawski avatar Nov 08 '20 12:11 npielawski

That is coding style not a technical issue. You may decide how you would like to implement it.

zhanghang1989 avatar Nov 08 '20 17:11 zhanghang1989

Well, I would have preferred not branching the repo and modifying it if that makes sense.

npielawski avatar Nov 08 '20 17:11 npielawski