model size mismatch for timm version==1.0.8

#4
by echoabc - opened

hello,I'm running this code:

import timm
from timm.layers import SwiGLUPacked
import torch

image.png
how can i modify?thanks!

Paige AI org

If you do:

timm.create_model("hf-hub:paige-ai/Virchow", pretrained=True, mlp_layer=SwiGLUPacked, act_layer=torch.nn.SiLU)

then the proper model args are parsed out of config.json automatically.

If you want to manually instantiate the model as in your code snippet, then you'll have to include the additional model_args from config.json:

timm.create_model(
    "vit_huge_patch14_224",
    pretrained=False,
    checkpoint_path=checkpoint_path,
    mlp_layer=SwiGLUPacked,
    act_layer=torch.nn.SiLU,
    img_size=224,
    init_values=1e-5,
    num_classes=0,
    mlp_ratio=5.3375,
    global_pool="",
    dynamic_img_size=True,
)

It works. Thank you very much.

echoabc changed discussion status to closed

Sign up or log in to comment