jeonsworld / ViT-pytorch

Pytorch reimplementation of the Vision Transformer (An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale)
MIT License
1.94k stars 370 forks source link

Key error when loading pre-trained weights #31

Open ParnianA opened 3 years ago

ParnianA commented 3 years ago

Hi, Thank you for your nice implementation. I get the following error when loading the pre-trained weights:

_KeyError: 'Transformer/encoderblock_0\MultiHeadDotProductAttention1/query\kernel is not a file in the archive'

Would you please help me with this?

Parnian

bqFirst commented 3 years ago

Hi, Thank you for your nice implementation. I get the following error when loading the pre-trained weights:

_KeyError: 'Transformer/encoderblock_0\MultiHeadDotProductAttention1/query\kernel is not a file in the archive'

Would you please help me with this?

Parnian I met the same problem. Have you solved it

cantabile-kwok commented 2 years ago

It seems to be the dir separator "\" and "/" in windows and linux. Maybe try to change query to query/ will help. In this way, your os.path will not add a "\" after the path if you are using windows.

charchit7 commented 2 years ago

Is it resolved? Even I had this issue for one of the models.

DanialP commented 2 years ago

It seems to be the dir separator "\" and "/" in windows and linux. Maybe try to change query to query/ will help. In this way, your os.path will not add a "\" after the path if you are using windows.

This worked for me. Attaching "/" on multiple lines, where windows will add "\\" instead.