PyTorch-StudioGAN
PyTorch-StudioGAN copied to clipboard
problem with loading pretrained styegan2 model
When I load with the pretrained stylegan2 model, it will show the errors : Error(s) in loading state_dict for Generator: Missing key(s) in state_dict: "mapping.fc2.weight", "mapping.fc2.bias", "mapping.fc3.weight", "mapping.fc3.bias", "mapping.fc4.weight", "mapping.fc4.bias", "mapping.fc5.weight", "mapping.fc5.bias", "mapping.fc6.weight", "mapping.fc6.bias", "mapping.fc7.weight", "mapping.fc7.bias". Unexpected key(s) in state_dict: "mapping.embed.weight", "mapping.embed.bias". size mismatch for mapping.fc0.weight: copying a param with shape torch.Size([512, 1024]) from checkpoint, the shape in current model is torch.Size([512, 512]).
and the code to load is from training.networks import Generator model=Generator(z_dim=512, c_dim=0, w_dim=512, img_resolution=32, img_channels=3).cuda()
checkpoint_path=('StyleGAN2-pretrain-cifar/model=G_ema-best-weights-step=970000.pth') inmodel=torch.load(checkpoint_path) print(inmodel) #model.load(inmodel) model.load_state_dict(inmodel['state_dict'], strict=True) model.eval() model.cuda() G=model
I want to know what the problem with it
Thanks
Hi does this problem still exist?!
Sorry, I didn't solve this question.
I have double checked the code and weight with latest settings and didn't face any problem. It seems like you have used checkpoint for StyleGAN2-ADA. Did you choose the proper config (src/configs/CIFAR10/StyleGAN2-ADA.yaml)?
Thanks for your help; I will try it.