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

Unable to load the state_dict for BinModel in demo example #8

Open
glgaines opened this issue May 12, 2023 · 5 comments
Open

Unable to load the state_dict for BinModel in demo example #8

glgaines opened this issue May 12, 2023 · 5 comments

Comments

@glgaines
Copy link

Working directly with the example code in https://github.com/dali92002/DocEnTR/blob/main/demo.ipynb

Tried the pretrained model params from the model zoo. when model.load_state_dict - Ran into the following error:

RuntimeError: Error(s) in loading state_dict for BinModel:
Missing key(s) in state_dict: "encoder.to_patch_embedding.2.weight", "encoder.to_patch_embedding.2.bias", "encoder.to_patch_embedding.3.weight", "encoder.to_patch_embedding.3.bias".

size mismatch for encoder.pos_embedding: copying a param with shape torch.Size([1, 1025, 768]) from checkpoint, the shape in current model is torch.Size([1, 257, 768]).

size mismatch for encoder.to_patch_embedding.1.weight: copying a param with shape torch.Size([768, 192]) from checkpoint, the shape in current model is torch.Size([768]).

size mismatch for patch_to_emb.weight: copying a param with shape torch.Size([768, 192]) from checkpoint, the shape in current model is torch.Size([768]).

size mismatch for decoder_pos_emb.weight: copying a param with shape torch.Size([1025, 768]) from checkpoint, the shape in current model is torch.Size([257, 768]).

size mismatch for to_pixels.weight: copying a param with shape torch.Size([192, 768]) from checkpoint, the shape in current model is torch.Size([768, 768]).

size mismatch for to_pixels.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([768]).
@glgaines glgaines changed the title Unable to lad the state_dict for BinModel in demo example Unable to load the state_dict for BinModel in demo example May 12, 2023
@daisyhaohao
Copy link

same problem

@masrur-ahmed
Copy link

masrur-ahmed commented Jun 8, 2023

try using python version 3.8.12

@dali92002
Copy link
Owner

You should be careful in using the right model, vit_model_size and vit_patch_size

@vm7608
Copy link

vm7608 commented Apr 19, 2024

same problem, anyone have the solution for that :( ?

@vm7608
Copy link

vm7608 commented Apr 20, 2024

I have found the following solution:

  • Specify package version: vit-pytorch==0.24.3 and einops==0.3.2
  • Choose the right pre trained ckpt and set the right value for setting and patch_size

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

5 participants