tianrun-chen / SAM-Adapter-PyTorch

Adapting Meta AI's Segment Anything to Downstream Tasks with Adapters and Prompts
MIT License
968 stars 83 forks source link

model.load_state_dict(sam_checkpoint, strict=False) #23

Closed xiaozhen228 closed 1 year ago

xiaozhen228 commented 1 year ago

RuntimeError: Error(s) in loading state_dict for SAM: size mismatch for image_encoder.pos_embed: copying a param with shape torch.Size([1, 64, 64, 1024]) from checkpoint, the shape in current model is torch.Size([1, 64, 64, 1280]).

Why I have such problem when I plan to load the weights? May be the code has some problems?

Jack-bo1220 commented 1 year ago

same question

tianrun-chen commented 1 year ago

Have you use the original implementation or have you changed the input size?

Jack-bo1220 commented 1 year ago

I have identified the potential cause of this error: using mismatched parameters and pre training models (such as using vit-l parameters and calling vit-h pretraining model). I have resolved it, thank you for your reply.