Following the procedures offered in README.md, I have finished to dowload 2 model files (100000_nets_ema.ckpt and wing.ckpt) and put them into corresponding directory. Then I run the script:
python main.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 \
--checkpoint_dir expr/checkpoints/celeba_hq \
--result_dir expr/results/celeba_hq \
--src_dir assets/representative/celeba_hq/src \
--ref_dir assets/representative/celeba_hq/ref
I got a RuntimeError like this:
-----------------------------------------------------output log---------------------------------------------------------------------------
Namespace(batch_size=8, beta1=0.0, beta2=0.99, checkpoint_dir='expr/checkpoints/celeba_hq', ds_iter=100000, eval_dir='expr/eval', eval_every=50000, f_lr=1e-06, hidden_dim=512, img_size=256, inp_dir='assets/representative/custom/female', lambda_cyc=1, lambda_ds=1, lambda_reg=1, lambda_sty=1, latent_dim=16, lm_path='expr/checkpoints/celeba_lm_mean.npz', lr=0.0001, mode='sample', num_domains=2, num_outs_per_domain=10, num_workers=4, out_dir='assets/representative/celeba_hq/src/female', print_every=10, randcrop_prob=0.5, ref_dir='assets/representative/celeba_hq/ref', result_dir='expr/results/celeba_hq', resume_iter=100000, sample_dir='expr/samples', sample_every=5000, save_every=10000, seed=777, src_dir='assets/representative/celeba_hq/src', style_dim=64, total_iters=100000, train_img_dir='data/celeba_hq/train', val_batch_size=32, val_img_dir='data/celeba_hq/val', w_hpf=1.0, weight_decay=0.0001, wing_path='expr/checkpoints/wing.ckpt')
Number of parameters of generator: 43467395
Number of parameters of mapping_network: 2438272
Number of parameters of style_encoder: 20916928
Number of parameters of discriminator: 20852290
Number of parameters of fan: 6333603
Initializing generator...
Initializing mapping_network...
Initializing style_encoder...
Initializing discriminator...
Preparing DataLoader for the generation phase...
Preparing DataLoader for the generation phase...
Loading checkpoint from expr/checkpoints/celeba_hq/100000_nets_ema.ckpt...
Traceback (most recent call last):
File "main.py", line 182, in
main(args)
File "main.py", line 73, in main
solver.sample(loaders)
File "/usr/local/lib64/python3.6/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
return func(*args, **kwargs)
File "/export/home/shipy/projects/stargan-v2/core/solver.py", line 178, in sample
self._load_checkpoint(args.resume_iter)
File "/export/home/shipy/projects/stargan-v2/core/solver.py", line 73, in _load_checkpoint
ckptio.load(step)
File "/export/home/shipy/projects/stargan-v2/core/checkpoint.py", line 48, in load
module.module.load_state_dict(module_dict[name])
File "/usr/local/lib64/python3.6/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Generator:
Missing key(s) in state_dict: "encode.6.conv1.weight", "encode.6.conv1.bias", "encode.6.conv2.weight", "encode.6.conv2.bias", "encode.6.norm1.weight", "encode.6.norm1.bias", "encode.6.norm2.weight", "encode.6.norm2.bias", "decode.6.conv1.weight", "decode.6.conv1.bias", "decode.6.conv2.weight", "decode.6.conv2.bias", "decode.6.norm1.fc.weight", "decode.6.norm1.fc.bias", "decode.6.norm2.fc.weight", "decode.6.norm2.fc.bias", "decode.6.conv1x1.weight", "hpf.filter".
Unexpected key(s) in state_dict: "decode.3.conv1x1.weight".
size mismatch for decode.3.conv1.weight: copying a param with shape torch.Size([256, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 3, 3]).
size mismatch for decode.3.conv1.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.3.conv2.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 3, 3]).
size mismatch for decode.3.conv2.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.3.norm2.fc.weight: copying a param with shape torch.Size([512, 64]) from checkpoint, the shape in current model is torch.Size([1024, 64]).
size mismatch for decode.3.norm2.fc.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for decode.4.conv1.weight: copying a param with shape torch.Size([128, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 512, 3, 3]).
size mismatch for decode.4.conv1.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.4.conv2.weight: copying a param with shape torch.Size([128, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 256, 3, 3]).
size mismatch for decode.4.conv2.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.4.norm1.fc.weight: copying a param with shape torch.Size([512, 64]) from checkpoint, the shape in current model is torch.Size([1024, 64]).
size mismatch for decode.4.norm1.fc.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for decode.4.norm2.fc.weight: copying a param with shape torch.Size([256, 64]) from checkpoint, the shape in current model is torch.Size([512, 64]).
size mismatch for decode.4.norm2.fc.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.4.conv1x1.weight: copying a param with shape torch.Size([128, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 512, 1, 1]).
size mismatch for decode.5.conv1.weight: copying a param with shape torch.Size([64, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]).
size mismatch for decode.5.conv1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for decode.5.conv2.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).
size mismatch for decode.5.conv2.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for decode.5.norm1.fc.weight: copying a param with shape torch.Size([256, 64]) from checkpoint, the shape in current model is torch.Size([512, 64]).
size mismatch for decode.5.norm1.fc.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.5.norm2.fc.weight: copying a param with shape torch.Size([128, 64]) from checkpoint, the shape in current model is torch.Size([256, 64]).
size mismatch for decode.5.norm2.fc.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.5.conv1x1.weight: copying a param with shape torch.Size([64, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 256, 1, 1]).
Guided by others' Issue, I reverted the code back to commit e28bdee, but it didn't work.
So, how to fix this case?
Following the procedures offered in README.md, I have finished to dowload 2 model files (100000_nets_ema.ckpt and wing.ckpt) and put them into corresponding directory. Then I run the script: python main.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 \ --checkpoint_dir expr/checkpoints/celeba_hq \ --result_dir expr/results/celeba_hq \ --src_dir assets/representative/celeba_hq/src \ --ref_dir assets/representative/celeba_hq/ref I got a RuntimeError like this: -----------------------------------------------------output log--------------------------------------------------------------------------- Namespace(batch_size=8, beta1=0.0, beta2=0.99, checkpoint_dir='expr/checkpoints/celeba_hq', ds_iter=100000, eval_dir='expr/eval', eval_every=50000, f_lr=1e-06, hidden_dim=512, img_size=256, inp_dir='assets/representative/custom/female', lambda_cyc=1, lambda_ds=1, lambda_reg=1, lambda_sty=1, latent_dim=16, lm_path='expr/checkpoints/celeba_lm_mean.npz', lr=0.0001, mode='sample', num_domains=2, num_outs_per_domain=10, num_workers=4, out_dir='assets/representative/celeba_hq/src/female', print_every=10, randcrop_prob=0.5, ref_dir='assets/representative/celeba_hq/ref', result_dir='expr/results/celeba_hq', resume_iter=100000, sample_dir='expr/samples', sample_every=5000, save_every=10000, seed=777, src_dir='assets/representative/celeba_hq/src', style_dim=64, total_iters=100000, train_img_dir='data/celeba_hq/train', val_batch_size=32, val_img_dir='data/celeba_hq/val', w_hpf=1.0, weight_decay=0.0001, wing_path='expr/checkpoints/wing.ckpt') Number of parameters of generator: 43467395 Number of parameters of mapping_network: 2438272 Number of parameters of style_encoder: 20916928 Number of parameters of discriminator: 20852290 Number of parameters of fan: 6333603 Initializing generator... Initializing mapping_network... Initializing style_encoder... Initializing discriminator... Preparing DataLoader for the generation phase... Preparing DataLoader for the generation phase... Loading checkpoint from expr/checkpoints/celeba_hq/100000_nets_ema.ckpt... Traceback (most recent call last): File "main.py", line 182, in
main(args)
File "main.py", line 73, in main
solver.sample(loaders)
File "/usr/local/lib64/python3.6/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
return func(*args, **kwargs)
File "/export/home/shipy/projects/stargan-v2/core/solver.py", line 178, in sample
self._load_checkpoint(args.resume_iter)
File "/export/home/shipy/projects/stargan-v2/core/solver.py", line 73, in _load_checkpoint
ckptio.load(step)
File "/export/home/shipy/projects/stargan-v2/core/checkpoint.py", line 48, in load
module.module.load_state_dict(module_dict[name])
File "/usr/local/lib64/python3.6/site-packages/torch/nn/modules/module.py", line 847, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Generator:
Missing key(s) in state_dict: "encode.6.conv1.weight", "encode.6.conv1.bias", "encode.6.conv2.weight", "encode.6.conv2.bias", "encode.6.norm1.weight", "encode.6.norm1.bias", "encode.6.norm2.weight", "encode.6.norm2.bias", "decode.6.conv1.weight", "decode.6.conv1.bias", "decode.6.conv2.weight", "decode.6.conv2.bias", "decode.6.norm1.fc.weight", "decode.6.norm1.fc.bias", "decode.6.norm2.fc.weight", "decode.6.norm2.fc.bias", "decode.6.conv1x1.weight", "hpf.filter".
Unexpected key(s) in state_dict: "decode.3.conv1x1.weight".
size mismatch for decode.3.conv1.weight: copying a param with shape torch.Size([256, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 3, 3]).
size mismatch for decode.3.conv1.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.3.conv2.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 3, 3]).
size mismatch for decode.3.conv2.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.3.norm2.fc.weight: copying a param with shape torch.Size([512, 64]) from checkpoint, the shape in current model is torch.Size([1024, 64]).
size mismatch for decode.3.norm2.fc.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for decode.4.conv1.weight: copying a param with shape torch.Size([128, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 512, 3, 3]).
size mismatch for decode.4.conv1.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.4.conv2.weight: copying a param with shape torch.Size([128, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 256, 3, 3]).
size mismatch for decode.4.conv2.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.4.norm1.fc.weight: copying a param with shape torch.Size([512, 64]) from checkpoint, the shape in current model is torch.Size([1024, 64]).
size mismatch for decode.4.norm1.fc.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for decode.4.norm2.fc.weight: copying a param with shape torch.Size([256, 64]) from checkpoint, the shape in current model is torch.Size([512, 64]).
size mismatch for decode.4.norm2.fc.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.4.conv1x1.weight: copying a param with shape torch.Size([128, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 512, 1, 1]).
size mismatch for decode.5.conv1.weight: copying a param with shape torch.Size([64, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]).
size mismatch for decode.5.conv1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for decode.5.conv2.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).
size mismatch for decode.5.conv2.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for decode.5.norm1.fc.weight: copying a param with shape torch.Size([256, 64]) from checkpoint, the shape in current model is torch.Size([512, 64]).
size mismatch for decode.5.norm1.fc.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for decode.5.norm2.fc.weight: copying a param with shape torch.Size([128, 64]) from checkpoint, the shape in current model is torch.Size([256, 64]).
size mismatch for decode.5.norm2.fc.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for decode.5.conv1x1.weight: copying a param with shape torch.Size([64, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 256, 1, 1]).
Guided by others' Issue, I reverted the code back to commit e28bdee, but it didn't work. So, how to fix this case?