Load Timm ViT model weights to huggingface ViT implementation #1810
-
Hello folks! I have a model which was originally trained using timm's VisionTransformer implementation. I have a few questions:
Thank you in advance for your help! Related discussion thread, but didn't answer my questions fully: huggingface/transformers#19305 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@anjali-chadha there is a conversion script in transformers, not sure it's up to date with the latest but should be minimal changes to make it work if out of date https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/convert_vit_timm_to_pytorch.py Not all timm vit models will have equivalent arch in transformers, there are some variations would need code additions on the transformer side. Most of the main ones would work though. Beware that norm epsilon tends to be wrong in many transformers vit model configs, it's 1e-6 not 1e-12. |
Beta Was this translation helpful? Give feedback.
@anjali-chadha there is a conversion script in transformers, not sure it's up to date with the latest but should be minimal changes to make it work if out of date https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/convert_vit_timm_to_pytorch.py
Not all timm vit models will have equivalent arch in transformers, there are some variations would need code additions on the transformer side. Most of the main ones would work though. Beware that norm epsilon tends to be wrong in many transformers vit model configs, it's 1e-6 not 1e-12.