IDEA-Research / detrex

detrex is a research platform for DETR-based object detection, segmentation, pose estimation and other visual recognition tasks.
https://detrex.readthedocs.io/en/latest/
Apache License 2.0
2.01k stars 209 forks source link

If it is possible to use features with more than 3 channels as input? #164

Closed momopusheen closed 1 year ago

momopusheen commented 1 year ago

Hi there, Thanks for your excellent work! I'm trying to train DINO on my own data, which are not regular RGB images but images with more channels (more than 7). I found that in torch, the input channel can be modifed by adding an extra conv layer, and then concat it with the original model. However, I didn't find examples of doing so in detrex (or detectron2). ;( So I wonder if I could do this with detrex. If possible, would you mind giving me an example?

Thanks a lot! XD

HaoZhang534 commented 1 year ago

You can add a layer that maps 7 channels to 3 channels before entering the backbone. But I recommend modifying the input channel of the first layer of the backbone from 3 to 7.

momopusheen commented 1 year ago

Thanks for your advice! Btw, I'm using swin transformer as backbone. Would it work if i modify the default 'in_chans' of it when defining backbone? here: def __init__( self, pretrain_img_size=224, patch_size=4, in_chans=3, embed_dim=96,

HaoZhang534 commented 1 year ago

@momopusheen Sure, you can change the number of input channels of the backbone.

momopusheen commented 1 year ago

Thank you sincerely!