ashkamath / mdetr

Apache License 2.0
980 stars 128 forks source link

Unexpected key(s) in state_dict: "transformer.text_encoder.embeddings.position_ids". #106

Open vdorbala opened 5 months ago

vdorbala commented 5 months ago

When running the demo script, I get - Unexpected key(s) in state_dict: "transformer.text_encoder.embeddings.position_ids".

while trying to load the model using - model, postprocessor = torch.hub.load('ashkamath/mdetr:main', 'mdetr_efficientnetB5', pretrained=True, return_postprocessor=True)

Does the model not work anymore?

iremeyiokur commented 3 months ago

It might be related with the transformers version. I solved the problem by adding strict=False into load_state_dict as proposed in the following link which basically ignores non-matching keys. I hope it will work for you.

https://discuss.pytorch.org/t/missing-keys-unexpected-keys-in-state-dict-when-loading-self-trained-model/22379/6

Buchimi commented 1 week ago

How can this be done in the colab?