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

size mismatch for block1.rep.0.pointwise.weight: copying a param with shape torch.Size([128, 64]) from checkpoint, the shape in current model is torch.Size([128, 64, 1, 1]). #101

Open
AnsonCNS opened this issue Sep 21, 2023 · 3 comments

Comments

@AnsonCNS
Copy link

After downloading the pretrain model xception-b5690688.pth and setting the correct path, I get the following error when running detect_from_video.py:

RuntimeError: Error(s) in loading state_dict for Xception:
        size mismatch for block1.rep.0.pointwise.weight: copying a param with shape torch.Size([128, 64]) from checkpoint, the shape in current model is torch.Size([128, 64, 1, 1]).
        size mismatch for block1.rep.3.pointwise.weight: copying a param with shape torch.Size([128, 128]) from checkpoint, the shape in current model is torch.Size([128, 128, 1, 1]).
        size mismatch for block2.rep.1.pointwise.weight: copying a param with shape torch.Size([256, 128]) from checkpoint, the shape in current model is torch.Size([256, 128, 1, 1]).
        size mismatch for block2.rep.4.pointwise.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([256, 256, 1, 1]).
        size mismatch for block3.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 256]) from checkpoint, the shape in current model is torch.Size([728, 256, 1, 1]).
        size mismatch for block3.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block4.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block4.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block4.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block5.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block5.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block5.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block6.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block6.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block6.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block7.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block7.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block7.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block8.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block8.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block8.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block9.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block9.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block9.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block10.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block10.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block10.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block11.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block11.rep.4.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block11.rep.7.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block12.rep.1.pointwise.weight: copying a param with shape torch.Size([728, 728]) from checkpoint, the shape in current model is torch.Size([728, 728, 1, 1]).
        size mismatch for block12.rep.4.pointwise.weight: copying a param with shape torch.Size([1024, 728]) from checkpoint, the shape in current model is torch.Size([1024, 728, 1, 1]).
        size mismatch for conv3.pointwise.weight: copying a param with shape torch.Size([1536, 1024]) from checkpoint, the shape in current model is torch.Size([1536, 1024, 1, 1]).
        size mismatch for conv4.pointwise.weight: copying a param with shape torch.Size([2048, 1536]) from checkpoint, the shape in current model is torch.Size([2048, 1536, 1, 1]).

NOTE: To get it to use the pretrained model, I had to make the following modifications:

In models.py, I modified the following

def return_pytorch04_xception(pretrained=True):
    # Raises warning "src not broadcastable to dst" but thats fine
    # model = xception(pretrained=False) # don't use pretrain, initialise random weights
    model = xception() # use pretrain

I also set the default pretrained parameter to True throughout the project, pretrained=True

Anyone else encountered this issue. How do we actually use the pretrained models?

@dvrkoo
Copy link

dvrkoo commented Nov 2, 2023

same error here, did you manage to fix it?

@qiuqiuni2000
Copy link

同样的错误在这里,你设法修复了它吗?

请问有解决了此问题的吗

@qiuqiuni2000
Copy link

Did you solve this problem?

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

No branches or pull requests

3 participants