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

VIT-tiny weights and config dont match? #92

Open
nemcekova opened this issue Sep 11, 2023 · 1 comment
Open

VIT-tiny weights and config dont match? #92

nemcekova opened this issue Sep 11, 2023 · 1 comment

Comments

@nemcekova
Copy link

Hello,
I'm trying to create VIT-tiny model, which is mentioned here.
My approach is:

  • I downloaded this repo
  • I downloaded weights and config file

First, I create model structure, as it was advised in the issue. I use options.ops get_training_arguments and cvnets get_model(), with vit-tiny.yaml config file. Model structure is saved correctly.

Secondly, I load the model structure and load_state_dict.

weights = 'vit-tiny.pt'
model = torch.load('vit_structure.pt', map_location=torch.device('cpu'))
model.load_state_dict(torch.load(weights, map_location=torch.device('cpu')))

That's where I'm getting following error:

raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for VisionTransformer:
Missing key(s) in state_dict: "patch_emb.0.block.conv.weight", "patch_emb.0.block.norm.weight", "patch_emb.0.block.norm.bias", "patch_emb.0.block.norm.running_mean", "patch_emb.0.block.norm.running_var", "patch_emb.1.block.conv.weight", "patch_emb.1.block.norm.weight", "patch_emb.1.block.norm.bias", "patch_emb.1.block.norm.running_mean", "patch_emb.1.block.norm.running_var", "patch_emb.2.block.conv.weight", "patch_emb.2.block.conv.bias", "post_transformer_norm.weight", "post_transformer_norm.bias", "pos_embed.pos_embed.pos_embed".
Unexpected key(s) in state_dict: "patch_emb.block.conv.weight", "patch_emb.block.conv.bias", "transformer.12.weight", "transformer.12.bias", "pos_embed.pe".

Any idea how is it possible and how to fix it?

Note: This approach works perfectly with mobile-vit

@Tranbaber
Copy link

@nemcekova
Hello! I'm trying to train MobileViT model, but I'm having the following problem and am asking for help

File "C:\Users\72344.conda\envs\MobileViTv2\Scripts\cvnets-train.exe_main_.py", line 4, in ModuleNotFoundError: No module named 'main_train'

And I tried to download this module, but show
"ERROR: Could not find a version that satisfies the requirement main_train (from versions: none)
ERROR: No matching distribution found for main_train"

Can you tell what can I do? Thank you very much!

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