sail-sg / iFormer

iFormer: Inception Transformer
Apache License 2.0
242 stars 19 forks source link

fit current timm import, and fix pos_embed shape when using 384 #20

Open leondgarse opened 1 year ago

leondgarse commented 1 year ago

Fit current timm register_model and to_2tuple import, and fix pos_embed shape when using 384. When using:

sys.path.append('../pytorch-image-models/')
import torch
from models import inception_transformer
tt = inception_transformer.iformer_small_384(pretrained=True)

met 3 errors:

ImportError: cannot import name 'register_model' from 'timm.models.registry'
ModuleNotFoundError: No module named 'timm.models.layers.helpers'
RuntimeError: Error(s) in loading state_dict for InceptionTransformer:
size mismatch for pos_embed1: copying a param with shape torch.Size([1, 56, 56, 96]) from checkpoint, the shape in current model is torch.Size([1, 96, 96, 96]).
size mismatch for pos_embed2: copying a param with shape torch.Size([1, 28, 28, 192]) from checkpoint, the shape in current model is torch.Size([1, 48, 48, 192]).
size mismatch for pos_embed3: copying a param with shape torch.Size([1, 14, 14, 320]) from checkpoint, the shape in current model is torch.Size([1, 24, 24, 320]).
size mismatch for pos_embed4: copying a param with shape torch.Size([1, 7, 7, 384]) from checkpoint, the shape in current model is torch.Size([1, 12, 12, 384]).
shangshang0912 commented 1 year ago

您的邮件已经收到。我会及时做出回复。