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

model not matched in notebooks/generate_captions.ipynb ? #7

Closed
YhQIAO opened this issue Jan 10, 2024 · 1 comment
Closed

model not matched in notebooks/generate_captions.ipynb ? #7

YhQIAO opened this issue Jan 10, 2024 · 1 comment

Comments

@YhQIAO
Copy link

YhQIAO commented Jan 10, 2024

run the code cell :
prefix_length = 10 model = ClipCaptionModel(prefix_length) model.load_state_dict(torch.load(model_path, map_location=CPU)) model = model.eval() device = CUDA(0) if is_gpu else "cpu" model = model.to(device)

and get error:
RuntimeError: Error(s) in loading state_dict for ClipCaptionModel:
Unexpected key(s) in state_dict: "gpt.transformer.h.0.attn.bias", "gpt.transformer.h.0.attn.masked_bias", "gpt.transformer.h.1.attn.bias", "gpt.transformer.h.1.attn.masked_bias", "gpt.transformer.h.2.attn.bias", "gpt.transformer.h.2.attn.masked_bias", "gpt.transformer.h.3.attn.bias", "gpt.transformer.h.3.attn.masked_bias", "gpt.transformer.h.4.attn.bias", "gpt.transformer.h.4.attn.masked_bias", "gpt.transformer.h.5.attn.bias", "gpt.transformer.h.5.attn.masked_bias", "gpt.transformer.h.6.attn.bias", "gpt.transformer.h.6.attn.masked_bias", "gpt.transformer.h.7.attn.bias", "gpt.transformer.h.7.attn.masked_bias", "gpt.transformer.h.8.attn.bias", "gpt.transformer.h.8.attn.masked_bias", "gpt.transformer.h.9.attn.bias", "gpt.transformer.h.9.attn.masked_bias", "gpt.transformer.h.10.attn.bias", "gpt.transformer.h.10.attn.masked_bias", "gpt.transformer.h.11.attn.bias", "gpt.transformer.h.11.attn.masked_bias".

@georghess
Copy link
Collaborator

Hi,
easiest thing is to set model.load_state_dict(model_weights, strict=False) . See rmokady/CLIP_prefix_caption#76 for reference.

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