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

Exporting weights to Pytorch StyleGAN2 implementation #7

Closed
adymaharana opened this issue Mar 29, 2022 · 1 comment
Closed

Exporting weights to Pytorch StyleGAN2 implementation #7

adymaharana opened this issue Mar 29, 2022 · 1 comment

Comments

@adymaharana
Copy link

adymaharana commented Mar 29, 2022

Hi,

Thanks for the wonderful work! I am trying to export the pretrained weights released in this repository to rosinality's implementation. I am using the export script from the stylegan2-ada-pytorch repository which is known to work for checkpoints using that repo (see here). However, when I used the converted Lafite checkpoints for the pretrained model COCO2014_CLIP_ViTB32_all_text.pkl, I am facing the following error:

raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Generator:
size mismatch for conv1.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for to_rgb1.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.0.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.1.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.2.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.3.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.4.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.5.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.6.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.7.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.8.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for convs.9.conv.modulation.weight: copying a param with shape torch.Size([256, 1024]) from checkpoint, the shape in current model is torch.Size([256, 512]).
size mismatch for convs.10.conv.modulation.weight: copying a param with shape torch.Size([256, 1024]) from checkpoint, the shape in current model is torch.Size([256, 512]).
size mismatch for convs.11.conv.modulation.weight: copying a param with shape torch.Size([128, 1024]) from checkpoint, the shape in current model is torch.Size([128, 512]).
size mismatch for to_rgbs.0.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for to_rgbs.1.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for to_rgbs.2.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for to_rgbs.3.conv.modulation.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
size mismatch for to_rgbs.4.conv.modulation.weight: copying a param with shape torch.Size([256, 1024]) from checkpoint, the shape in current model is torch.Size([256, 512]).
size mismatch for to_rgbs.5.conv.modulation.weight: copying a param with shape torch.Size([128, 1024]) from checkpoint, the shape in current model is torch.Size([128, 512]).

Any idea, why this mismatch might be happening?

@drboog
Copy link
Owner

drboog commented Mar 29, 2022

Hi,
Our architecture is different from original StyleGAN2. Also, we use fmap=1 by default, which influences the channel number, see

fmap = 1.

Lafite/train.py

Line 243 in a79c66a

spec.fmaps = 1 if res >= 512 else fmap

Lafite/train.py

Line 251 in a79c66a

args.G_kwargs.synthesis_kwargs.channel_base = args.D_kwargs.channel_base = int(spec.fmaps * 32768)

@drboog drboog closed this as completed Apr 4, 2022
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

2 participants