huggingface / pytorch-image-models

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more

Home Page:https://huggingface.co/docs/timm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

By using timm.create, how to download weights from url instead of HF?

maywander opened this issue · comments

I want to use url to load vit_base_patch8_224, and dino from hf_hub, so how can I do this?

The model download from vit_base_patch8_224(url) will generate embedding size of (, 784, 768). While the model download from vit_base_patch8_224(hf-hub) will generate embedding size of (, 785, 768) . It's confusing.

@maywander no idea how you got 784 so you'd have to provide complete reproduction, just instantiating that model without loading any pretrained weights will yield 785. 784 vs 785 is the difference of a class token but all the patch8 base models have a class token enabled, there are none without.

You can download the weight files manually from the hub and do something like #2069 to force loading from a local file if you need to