Open eflorico opened 5 months ago
Thanks for the report @eflorico .
Instead of updating new weights, we can probably overwrite the load_state_dict()
method of those respective base classes? There are only a handful of those so this should be tractable.
🐛 Describe the bug
fasterrcnn_resnet50_fpn()
includes code to edit weights on-the-fly while loading them: https://github.com/pytorch/vision/blob/bf01bab6125c5f1152e4f336b470399e52a8559d/torchvision/models/detection/faster_rcnn.py#L578-578Therefore, if you attempt to load weights after model instantiation, you will get wrong (but only slightly wrong!) weights:
Instead, I would suggest applying the weight edits to the weights themselves, so that you can load e.g.
FasterRCNN_ResNet50_FPN_Weights.COCO_V1_FIXED
usingload_state_dict
, without having to dig into the torchvision source and manually editing weights yourself.Versions
Torchvision 0.18.1