ondyari / FaceForensics

Github of the FaceForensics dataset
http://niessnerlab.org/projects/roessler2018faceforensics.html
Other
2.34k stars 530 forks source link

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 12 months ago

AnsonCNS commented 12 months ago

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 commented 10 months ago

same error here, did you manage to fix it?