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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the pretrained model weights #15

Closed
llj110 opened this issue Jun 18, 2024 · 5 comments
Closed

the pretrained model weights #15

llj110 opened this issue Jun 18, 2024 · 5 comments

Comments

@llj110
Copy link

llj110 commented Jun 18, 2024

How can I load the parameters for both the backbone and projector together? I can only load the backbone parameters, and loading both results in an error, even when using the full checkpoint which contains weights for both the backbone and projection head

@whj363636
Copy link
Collaborator

Hi @llj110

Thanks for your interest. The backbone and projector components have been wrapped in a Sequential module called "classifier," while the prompter and classifier are further grouped within another Sequential module called 'model'. Therefore, if your intention is to solely reload the weights for the 'classifier' component, rather than the entire 'model', in both train.py and eval.py, you can maintain the code and simply select the last module from the pretrained model. This module contains the full weights of the backbone and projector.

@llj110
Copy link
Author

llj110 commented Jun 18, 2024

classifier = nn.Sequential(backbone, projector).cuda()
state_dict = torch.load(args.pretrained_model_path, map_location='cpu')
classifier.load_state_dict(state_dict)
Thanks for your reply. My question is how to load the pretrained model parameters for the classifier using dino_vitbase16_pretrain.pth. The model I downloaded can only load the backbone parameters, but the parameters for the DINOHead cannot be loaded. This issue persists even when I use dino_vitbase16_pretrain_full_checkpoint.pth, which contains the weights for both the backbone and the projector head.

@llj110
Copy link
Author

llj110 commented Jun 18, 2024

I can just run this code by adjust the code to
state_dict = torch.load(args.pretrained_model_path, map_location='cpu')
backbone.load_state_dict(state_dict)
classifier = nn.Sequential(backbone, projector).cuda(). Therefore, I would like to ask if it is possible to provide the pretrained weights for the classifier.

@whj363636
Copy link
Collaborator

I see. Please refer to #4.

@llj110
Copy link
Author

llj110 commented Jun 18, 2024

Thanks for your valuable reply. I will try to obtain the pretrained SimGCD model

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

2 participants