facebookresearch / detr

End-to-End Object Detection with Transformers
Apache License 2.0
13.42k stars 2.42k forks source link

How to resume parameters from checkpoint only for the transformer? #532

Closed Rares926 closed 2 years ago

Rares926 commented 2 years ago

Basically I have changed the backbone of the initial model from ResNet50 to MobilenetV2, but after some training I realized that without pretrained weights the model will converge extremely slow. From this I understood that I have to load the pretrained weights somehow only for the transformer parts.

Is that possible? Any information on how I could do this is gladly welcomed.

I tried something like : model_without_ddp.transformer.load_state_dict(checkpoint['model'],strict=False) thinking that with the strict parameter set to false the values would be loaded only for the transformer but i even if the code does not error out I don't see any changes in the transformer weights.

So basically I found out that I can parse the loaded checkpoint and delete unnecessary weights from the dict before loading them into the model. That being said I'll close this issue giving that it has been resolved.