ClipCaptionModel errors
LiXinghui-666 opened this issue · 3 comments
LiXinghui-666 commented
Hi, @Colin97 when running the following code of caption.py in PATH (openshape-demo-support/openshape/demo)
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
prefix_length = 10
model = ClipCaptionModel(prefix_length)
# print(model.gpt_embedding_size)
model.load_state_dict(torch.load(hf_hub_download('OpenShape/clipcap-cc', 'conceptual_weights.pt', token=True), map_location='cpu'))
report 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".
what is wrong?
Colin97 commented
It seems that the package "transformers" has recently been updated. Using the old version 4.29.2 can resolve the problem.
LiXinghui-666 commented
It seems that the package "transformers" has recently been updated. Using the old version 4.29.2 can resolve the problem.
This works for me. Thanks!
Kaisor-Yuan commented
I followed your suggestion, but it remained false. Is there any other method?
It seems that the package "transformers" has recently been updated. Using the old version 4.29.2 can resolve the problem.