Using detr with custom backbone

I would like to use detr model with a fine tunned resnet-50 backbone, but I can see how to configure it.

Somebody know how to do it ?

Thanks,
Paolo

Hi,

Yes this is now supported using the AutoBackbone class.

Here’s how to do that:

from transformers import DetrConfig, DetrForObjectDetection

config = DetrConfig(backbone="microsoft/resnet50", use_pretrained_backbone=True)

model = DetrForObjectDetection(config)

Also, here’s how to randomly initialize a DETR model with a custom ResNet model:

from transformers import DetrConfig, ResNetConfig, DetrForObjectDetection

backbone_config = ResNetConfig.from_pretrained("microsoft/resnet-50", out_indices=[0,1,2,3])

config = DetrConfig(backbone_config=backbone_config)

model = DetrForObjectDetection(config)

Hi Niels,
thank you for your answer.

Paolo