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

How to call the trained weights for testing #28

Open
zhaiyuyang opened this issue Sep 27, 2024 · 2 comments
Open

How to call the trained weights for testing #28

zhaiyuyang opened this issue Sep 27, 2024 · 2 comments

Comments

@zhaiyuyang
Copy link

It seems that the model saves the weights in the format net_xxx.pth during training. However, during testing, I made the following modifications according to your method:
self.model_t = Namespace() self.model_t.name = 'vit_small_patch16_224_dino' self.model_t.kwargs = dict(pretrained=False, checkpoint_path= 'model/pretrain/net_100.pth', pretrained_strict=False, strict=True, img_size=self.size, teachers=[3, 6, 9], neck=[12]) # self.model_t.kwargs = dict(pretrained=True, checkpoint_path='', strict=True, img_size=self.size, teachers=[3, 6, 9], neck=[12]) self.model_f = Namespace() self.model_f.name = 'fusion' self.model_f.kwargs = dict(pretrained=False, checkpoint_path='', strict=False, dim=384, mul=1) self.model_s = Namespace() self.model_s.name = 'de_vit_small_patch16_224_dino' self.model_s.kwargs = dict(pretrained=False, checkpoint_path='', strict=False, img_size=self.size, students=[3, 6, 9], depth=9) self.model = Namespace() self.model.name = 'vitad' self.model.kwargs = dict(pretrained=False, checkpoint_path='', strict=True, model_t=self.model_t, model_f=self.model_f, model_s=self.model_s)
But an error occurred during execution:
RuntimeError: Error(s) in loading state_dict for ViT_Encoder:`,"Clearly, the weight file does not match the model input."。
"Could you please advise me on how to resolve this? Thank you in advance for your response."

@zhaiyuyang
Copy link
Author

Can someone come to help me?

@zhangzjn
Copy link
Owner

You can modify trainer.resume_dir to LOGDIR, or model.kwargs['checkpoint_path'] to LOGDIR/net_xxx.pth. I hope this helps you.

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