Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fasterrcnn_resnet50_fpn edits weights on-the-fly #8502

Open
eflorico opened this issue Jun 23, 2024 · 0 comments
Open

fasterrcnn_resnet50_fpn edits weights on-the-fly #8502

eflorico opened this issue Jun 23, 2024 · 0 comments

Comments

@eflorico
Copy link

馃悰 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-578

Therefore, if you attempt to load weights after model instantiation, you will get wrong (but only slightly wrong!) weights:

# First:
model = fasterrcnn_resnet50_fpn()

# Later:
weights = FasterRCNN_ResNet50_FPN_Weights.COCO_V1
model.load_state_dict(weights.get_state_dict())

# Resulting weights will be wrong!

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 using load_state_dict, without having to dig into the torchvision source and manually editing weights yourself.

Versions

Torchvision 0.18.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant