Lotayou / Face-Renovation

Official repository of the paper "HiFaceGAN: Face Renovation via Collaborative Suppression and Replenishment".
https://arxiv.org/abs/2005.05005
GNU General Public License v3.0
284 stars 49 forks source link

Pretrained checkpoint load problem #41

Open ialex2004 opened 3 years ago

ialex2004 commented 3 years ago

Hello, I tried to load the pretrained checkpoints and faced a prblem of weights mismatch, code:

import os, torch
from collections import OrderedDict

import data
# change config file for ablation study...
from options.config_hifacegan import TestOptions
from models.pix2pix_model import Pix2PixModel
from util.visualizer import Visualizer
from util import html
import numpy as np
import cv2
from tqdm import tqdm

os.environ['CUDA_VISIBLE_DEVICES'] = '0'

torch.backends.cudnn.benchmark = True

opt = TestOptions()
opt.name='4xsr'
# opt.checkpoints_dir='checkpoints/4xsr/'

# dataloader = data.create_dataloader(opt)

model = Pix2PixModel(opt)
### 20200218 Critical Bug
# When model is set to eval mode, the generated image
# is not enhanced whatsoever, with almost 0 residual
# when turned to training mode, it behaves as expected.
###
#model.eval()
#model.netG.eval()
model.netG.train()

error: ` Network [HiFaceGANGenerator] was created. Total number of parameters: 130.6 million. To see the architecture, do print(network).

RuntimeError Traceback (most recent call last)

in 22 # dataloader = data.create_dataloader(opt) 23 ---> 24 model = Pix2PixModel(opt) 25 ### 20200218 Critical Bug 26 # When model is set to eval mode, the generated image ~/git/Face-Renovation/models/pix2pix_model.py in __init__(self, opt) 24 else torch.ByteTensor 25 ---> 26 self.netG, self.netD, self.netE = self.initialize_networks(opt) 27 28 # set loss functions ~/git/Face-Renovation/models/pix2pix_model.py in initialize_networks(self, opt) 186 187 if not opt.isTrain or opt.continue_train: --> 188 netG = util.load_network(netG, 'G', opt.which_epoch, opt) 189 if opt.isTrain: 190 netD = util.load_network(netD, 'D', opt.which_epoch, opt) ~/git/Face-Renovation/util/util.py in load_network(net, label, epoch, opt) 207 save_path = os.path.join(save_dir, save_filename) 208 weights = torch.load(save_path) --> 209 net.load_state_dict(weights) 210 print('Load checkpoint from path: ', save_path) 211 return net ~/.conda/envs/face-renovation/lib/python3.7/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict) 1043 0, 'Unexpected key(s) in state_dict: {}. '.format( 1044 ', '.join('"{}"'.format(k) for k in unexpected_keys))) -> 1045 if len(missing_keys) > 0: 1046 error_msgs.insert( 1047 0, 'Missing key(s) in state_dict: {}. '.format( RuntimeError: Error(s) in loading state_dict for HiFaceGANGenerator: Missing key(s) in state_dict: "encoder.head.0.weight", "encoder.encoder_0.0.logit.0.weight", "encoder.encoder_0.0.logit.1.weight", "encoder.encoder_0.0.logit.1.bias", "encoder.encoder_0.1.weight", "encoder.encoder_0.1.bias", "encoder.encoder_1.0.logit.0.weight", "encoder.encoder_1.0.logit.1.weight", "encoder.encoder_1.0.logit.1.bias", "encoder.encoder_1.1.weight", "encoder.encoder_1.1.bias", "encoder.encoder_2.0.logit.0.weight", "encoder.encoder_2.0.logit.1.weight", "encoder.encoder_2.0.logit.1.bias", "encoder.encoder_2.1.weight", "encoder.encoder_2.1.bias", "encoder.encoder_3.0.logit.0.weight", "encoder.encoder_3.0.logit.1.weight", "encoder.encoder_3.0.logit.1.bias", "encoder.encoder_3.1.weight", "encoder.encoder_3.1.bias", "encoder.encoder_4.0.logit.0.weight", "encoder.encoder_4.0.logit.1.weight", "encoder.encoder_4.0.logit.1.bias", "encoder.encoder_4.1.weight", "encoder.encoder_4.1.bias". size mismatch for fc.weight: copying a param with shape torch.Size([768, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 3, 3, 3]). size mismatch for fc.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.conv_0.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.conv_0.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for head_0.conv_0.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.conv_0.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for head_0.conv_1.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.conv_1.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for head_0.conv_1.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.conv_1.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for head_0.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for head_0.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for head_0.norm_0.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for head_0.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for head_0.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for head_0.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for head_0.norm_1.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_0.conv_0.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.conv_0.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for G_middle_0.conv_0.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.conv_0.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for G_middle_0.conv_1.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.conv_1.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for G_middle_0.conv_1.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.conv_1.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for G_middle_0.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for G_middle_0.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_0.norm_0.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_0.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_0.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for G_middle_0.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_0.norm_1.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_1.conv_0.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.conv_0.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for G_middle_1.conv_0.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.conv_0.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for G_middle_1.conv_1.bias: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.conv_1.weight_orig: copying a param with shape torch.Size([768, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 3, 3]). size mismatch for G_middle_1.conv_1.weight_u: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.conv_1.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for G_middle_1.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for G_middle_1.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_1.norm_0.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_1.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for G_middle_1.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 1024, 3, 3]). size mismatch for G_middle_1.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for G_middle_1.norm_1.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for ups.0.conv_0.bias: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.conv_0.weight_orig: copying a param with shape torch.Size([384, 768, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 1024, 3, 3]). size mismatch for ups.0.conv_0.weight_u: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.conv_0.weight_v: copying a param with shape torch.Size([6912]) from checkpoint, the shape in current model is torch.Size([9216]). size mismatch for ups.0.conv_1.bias: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.conv_1.weight_orig: copying a param with shape torch.Size([384, 384, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 3, 3]). size mismatch for ups.0.conv_1.weight_u: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.conv_1.weight_v: copying a param with shape torch.Size([3456]) from checkpoint, the shape in current model is torch.Size([4608]). size mismatch for ups.0.conv_s.weight_orig: copying a param with shape torch.Size([384, 768, 1, 1]) from checkpoint, the shape in current model is torch.Size([512, 1024, 1, 1]). size mismatch for ups.0.conv_s.weight_u: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.conv_s.weight_v: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for ups.0.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for ups.0.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for ups.0.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 512, 3, 3]). size mismatch for ups.0.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for ups.0.norm_0.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for ups.0.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.0.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 512, 3, 3]). size mismatch for ups.0.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.0.norm_1.mlp_beta.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.0.norm_s.param_free_norm.running_mean: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for ups.0.norm_s.param_free_norm.running_var: copying a param with shape torch.Size([768]) from checkpoint, the shape in current model is torch.Size([1024]). size mismatch for ups.0.norm_s.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 512, 3, 3]). size mismatch for ups.0.norm_s.mlp_gamma.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for ups.0.norm_s.mlp_beta.weight: copying a param with shape torch.Size([768, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 128, 3, 3]). size mismatch for ups.1.conv_0.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.conv_0.weight_orig: copying a param with shape torch.Size([192, 384, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 512, 3, 3]). size mismatch for ups.1.conv_0.weight_u: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.conv_0.weight_v: copying a param with shape torch.Size([3456]) from checkpoint, the shape in current model is torch.Size([4608]). size mismatch for ups.1.conv_1.bias: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.conv_1.weight_orig: copying a param with shape torch.Size([192, 192, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 256, 3, 3]). size mismatch for ups.1.conv_1.weight_u: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.conv_1.weight_v: copying a param with shape torch.Size([1728]) from checkpoint, the shape in current model is torch.Size([2304]). size mismatch for ups.1.conv_s.weight_orig: copying a param with shape torch.Size([192, 384, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 512, 1, 1]). size mismatch for ups.1.conv_s.weight_u: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.conv_s.weight_v: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.1.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.1.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.1.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]). size mismatch for ups.1.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.1.norm_0.mlp_beta.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.1.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.1.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]). size mismatch for ups.1.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.1.norm_1.mlp_beta.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.1.norm_s.param_free_norm.running_mean: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.1.norm_s.param_free_norm.running_var: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([512]). size mismatch for ups.1.norm_s.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]). size mismatch for ups.1.norm_s.mlp_gamma.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.1.norm_s.mlp_beta.weight: copying a param with shape torch.Size([384, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 128, 3, 3]). size mismatch for ups.2.conv_0.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.conv_0.weight_orig: copying a param with shape torch.Size([96, 192, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 256, 3, 3]). size mismatch for ups.2.conv_0.weight_u: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.conv_0.weight_v: copying a param with shape torch.Size([1728]) from checkpoint, the shape in current model is torch.Size([2304]). size mismatch for ups.2.conv_1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.conv_1.weight_orig: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.conv_1.weight_u: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.conv_1.weight_v: copying a param with shape torch.Size([864]) from checkpoint, the shape in current model is torch.Size([1152]). size mismatch for ups.2.conv_s.weight_orig: copying a param with shape torch.Size([96, 192, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 256, 1, 1]). size mismatch for ups.2.conv_s.weight_u: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.conv_s.weight_v: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.2.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.2.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.2.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.2.norm_0.mlp_beta.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.2.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([96, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.norm_1.mlp_shared.0.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.2.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.norm_1.mlp_beta.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.norm_s.param_free_norm.running_mean: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.2.norm_s.param_free_norm.running_var: copying a param with shape torch.Size([192]) from checkpoint, the shape in current model is torch.Size([256]). size mismatch for ups.2.norm_s.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.2.norm_s.mlp_gamma.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.2.norm_s.mlp_beta.weight: copying a param with shape torch.Size([192, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 128, 3, 3]). size mismatch for ups.3.conv_0.bias: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.conv_0.weight_orig: copying a param with shape torch.Size([48, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 128, 3, 3]). size mismatch for ups.3.conv_0.weight_u: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.conv_0.weight_v: copying a param with shape torch.Size([864]) from checkpoint, the shape in current model is torch.Size([1152]). size mismatch for ups.3.conv_1.bias: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.conv_1.weight_orig: copying a param with shape torch.Size([48, 48, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for ups.3.conv_1.weight_u: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.conv_1.weight_v: copying a param with shape torch.Size([432]) from checkpoint, the shape in current model is torch.Size([576]). size mismatch for ups.3.conv_s.weight_orig: copying a param with shape torch.Size([48, 96, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 128, 1, 1]). size mismatch for ups.3.conv_s.weight_u: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.conv_s.weight_v: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_0.param_free_norm.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_0.param_free_norm.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([96, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 64, 3, 3]). size mismatch for ups.3.norm_0.mlp_shared.0.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_0.mlp_gamma.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.3.norm_0.mlp_beta.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.3.norm_1.param_free_norm.running_mean: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.norm_1.param_free_norm.running_var: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.norm_1.mlp_shared.0.weight: copying a param with shape torch.Size([48, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for ups.3.norm_1.mlp_shared.0.bias: copying a param with shape torch.Size([48]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for ups.3.norm_1.mlp_gamma.weight: copying a param with shape torch.Size([48, 48, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for ups.3.norm_1.mlp_beta.weight: copying a param with shape torch.Size([48, 48, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for ups.3.norm_s.param_free_norm.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_s.param_free_norm.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_s.mlp_shared.0.weight: copying a param with shape torch.Size([96, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 64, 3, 3]). size mismatch for ups.3.norm_s.mlp_shared.0.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([128]). size mismatch for ups.3.norm_s.mlp_gamma.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for ups.3.norm_s.mlp_beta.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]). size mismatch for to_rgbs.0.weight: copying a param with shape torch.Size([3, 384, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 512, 3, 3]). size mismatch for to_rgbs.1.weight: copying a param with shape torch.Size([3, 192, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 256, 3, 3]). size mismatch for to_rgbs.2.weight: copying a param with shape torch.Size([3, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 128, 3, 3]). size mismatch for to_rgbs.3.weight: copying a param with shape torch.Size([3, 48, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 64, 3, 3]). ` Tested with torch 1.8.1, 1.6, 1.5
wataridori2010 commented 3 years ago

I got a similar issue yesterday. in my case, just insert below lines ahead of net.load_state_dict(weights) of load_network function of util.py

import torch.nn as nn    
net = nn.DataParallel(net)

please refer this issue hope it works.

wataridori2010 commented 3 years ago

oh but I changed it to net.load_state_dict(weights, strict=False) . so I am not sure my result is correct. sorry.

ZhangYuef commented 3 years ago

It's the problem related to the setting of hyperparameters. To stay tune with the pretrained model, we should set options/config_hifacegan.py:

netG='lipspade'
#ngf = 64 # set to 48 for Titan X 12GB card
ngf=48

Same as issue #26 .