SHShim0513 / SD-VITON

[AAAI 2024] Towards Squeezing-Averse Virtual Try-On via Sequential Deformation.
https://arxiv.org/pdf/2312.15861.pdf
122 stars 14 forks source link

Runtime Error on test #11

Open syedhaideralizaidi opened 6 months ago

syedhaideralizaidi commented 6 months ago

Do anyone know how to fix this issue?

File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 2152, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for SPADEGenerator: Missing key(s) in state_dict: "up_4.conv_0.weight_orig", "up_4.conv_0.weight", "up_4.conv_0.weight_u", "up_4.conv_0.bias", "up_4.conv_0.weight_orig", "up_4.conv_0.weight_u", "up_4.conv_0.weight_v", "up_4.conv_1.weight_orig", "up_4.conv_1.weight", "up_4.conv_1.weight_u", "up_4.conv_1.bias", "up_4.conv_1.weight_orig", "up_4.conv_1.weight_u", "up_4.conv_1.weight_v", "up_4.conv_s.weight_orig", "up_4.conv_s.weight", "up_4.conv_s.weight_u", "up_4.conv_s.weight_orig", "up_4.conv_s.weight_u", "up_4.conv_s.weight_v", "up_4.norm_0.noise_scale", "up_4.norm_0.conv_shared.0.weight", "up_4.norm_0.conv_shared.0.bias", "up_4.norm_0.conv_gamma.weight", "up_4.norm_0.conv_gamma.bias", "up_4.norm_0.conv_beta.weight", "up_4.norm_0.conv_beta.bias", "up_4.norm_1.noise_scale", "up_4.norm_1.conv_shared.0.weight", "up_4.norm_1.conv_shared.0.bias", "up_4.norm_1.conv_gamma.weight", "up_4.norm_1.conv_gamma.bias", "up_4.norm_1.conv_beta.weight", "up_4.norm_1.conv_beta.bias", "up_4.norm_s.noise_scale", "up_4.norm_s.conv_shared.0.weight", "up_4.norm_s.conv_shared.0.bias", "up_4.norm_s.conv_gamma.weight", "up_4.norm_s.conv_gamma.bias", "up_4.norm_s.conv_beta.weight", "up_4.norm_s.conv_beta.bias". size mismatch for conv_img.weight: copying a param with shape torch.Size([3, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([4, 32, 3, 3]). size mismatch for conv_img.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([4]).

davvvy commented 6 months ago

I have the same problem

VishalYadavShorthillsAI commented 5 months ago

I am also facing the same issue. Namespace(gpu_ids='0', workers=4, batch_size=1, fp16=False, test_name='sample', dataroot='/content/drive/MyDrive', datamode='test', data_list='/content/drive/MyDrive/datasets/test_pairs.txt', output_dir=None, datasetting='unpaired', fine_width=768, fine_height=1024, tensorboard_dir='tensorboard', checkpoint_dir='checkpoints', tocg_checkpoint='/content/drive/MyDrive/tocg.pth', gen_checkpoint='/content/drive/MyDrive/toig.pth', tensorboard_count=100, shuffle=False, semantic_nc=13, output_nc=13, gen_semantic_nc=7, warp_feature='T1', out_layer='relu', upsample='bilinear', occlusion=True, cond_G_ngf=96, cond_G_input_width=192, cond_G_input_height=256, cond_G_num_layers=5, norm_G='spectralaliasinstance', ngf=64, init_type='xavier', init_variance=0.02, num_upsampling_layers='most', composition_mask=False) Start to test %s! /usr/local/lib/python3.10/site-packages/torch/utils/data/dataloader.py:558: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary. warnings.warn(_create_warning_msg( Network [SPADEGenerator] was created. Total number of parameters: 100.5 million. To see the architecture, do print(network). Traceback (most recent call last): File "/content/SD-VITON/test_generator.py", line 266, in main() File "/content/SD-VITON/test_generator.py", line 257, in main load_checkpoint_G(generator, opt.gen_checkpoint) File "/content/SD-VITON/test_generator.py", line 89, in load_checkpoint_G model.load_state_dict(new_state_dict, strict=True) File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2153, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for SPADEGenerator: size mismatch for conv_img.weight: copying a param with shape torch.Size([4, 32, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 32, 3, 3]). size mismatch for conv_img.bias: copying a param with shape torch.Size([4]) from checkpoint, the shape in current model is torch.Size([3]).

diegodinho3 commented 4 months ago

In network_generator.py the architecture is constructed depending on the composition mask:

if opt.composition_mask: self.conv_img = nn.Conv2d(nf, 4, kernel_size=3, padding=1) self.sigmoid = nn.Sigmoid() else: self.conv_img = nn.Conv2d(nf, 3, kernel_size=3, padding=1)

So the checkpoint assumes that the composition mask is "active". You must include the flag --composition_mask