junyanz / pytorch-CycleGAN-and-pix2pix

Image-to-Image Translation in PyTorch
Other
22.8k stars 6.29k forks source link

HELP: Error(s) in loading state_dict for ResnetGenerator: #1579

Open tjnkyqcy opened 1 year ago

tjnkyqcy commented 1 year ago

Traceback (most recent call last): File "C:/Users/Administrator/Desktop/pytorch-CycleGAN-and-pix2pix-master/test.py", line 52, in model.setup(opt) # regular setup: load and print networks; create schedulers File "C:\Users\Administrator\Desktop\pytorch-CycleGAN-and-pix2pix-master\models\base_model.py", line 88, in setup self.load_networks(load_suffix) File "C:\Users\Administrator\Desktop\pytorch-CycleGAN-and-pix2pix-master\models\base_model.py", line 199, in load_networks net.load_state_dict(state_dict) #qcy,strict=False File "E:\Anaconda3\envs\pytorch-gpu-Gan\lib\site-packages\torch\nn\modules\module.py", line 1482, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for ResnetGenerator: Missing key(s) in state_dict: "model.10.conv_block.6.weight", "model.10.conv_block.6.bias", "model.11.conv_block.6.weight", "model.11.conv_block.6.bias", "model.12.conv_block.6.weight", "model.12.conv_block.6.bias", "model.13.conv_block.6.weight", "model.13.conv_block.6.bias", "model.14.conv_block.6.weight", "model.14.conv_block.6.bias", "model.15.conv_block.6.weight", "model.15.conv_block.6.bias", "model.16.conv_block.6.weight", "model.16.conv_block.6.bias", "model.17.conv_block.6.weight", "model.17.conv_block.6.bias", "model.18.conv_block.6.weight", "model.18.conv_block.6.bias". Unexpected key(s) in state_dict: "model.10.conv_block.5.weight", "model.10.conv_block.5.bias", "model.11.conv_block.5.weight", "model.11.conv_block.5.bias", "model.12.conv_block.5.weight", "model.12.conv_block.5.bias", "model.13.conv_block.5.weight", "model.13.conv_block.5.bias", "model.14.conv_block.5.weight", "model.14.conv_block.5.bias", "model.15.conv_block.5.weight", "model.15.conv_block.5.bias", "model.16.conv_block.5.weight", "model.16.conv_block.5.bias", "model.17.conv_block.5.weight", "model.17.conv_block.5.bias", "model.18.conv_block.5.weight", "model.18.conv_block.5.bias".

What do I need to modify?

iosovi commented 1 year ago

Did you solve this? I am having the exact same problem, I trained pix2pix with the resnet_9blocks generator and I get the exact same error when trying to load.

grgeosteve commented 1 year ago

I am using cycle_gan with resnet_9blocks so it may be different, but adding --no_dropout solved the problem for me.

wcyjerry commented 1 year ago

I am using cycle_gan with resnet_9blocks so it may be different, but adding --no_dropout solved the problem for me.

Solved for me thx

wgqt1zl commented 1 year ago

I am using cycle_gan with resnet_9blocks so it may be different, but adding --no_dropout solved the problem for me.

also solved for me, thanks

arrrrr3186 commented 7 months ago

is this the correct approach? or any catch is there?