Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leondgarse
Copy link

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]).
  • For the first 2, adds a try except block fitting current newest timm imports.
  • For the 3rd one, I think it should use 224 calculating the first num_patches for any input image size.

@shangshang0912
Copy link

shangshang0912 commented Jan 14, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants