DeblurGAN icon indicating copy to clipboard operation
DeblurGAN copied to clipboard

unexpected key "model.0.weight" in state_dict

Open dm0288 opened this issue 7 years ago • 5 comments

Hi, When I run test.py as per instructions in readme file, I get the 'unexpected key "model.0.weight" in state_dict' error.

$ python test.py --dataroot ../BlurredImages/ --model test --dataset_mode single --learn_residual------------ Options ------------- aspect_ratio: 1.0 batchSize: 1 checkpoints_dir: ./checkpoints dataroot: ../BlurredImages/ dataset_mode: single display_id: 1 display_port: 8097 display_single_pane_ncols: 0 display_winsize: 256 fineSize: 256 gan_type: wgan-gp gpu_ids: [0] how_many: 5000 input_nc: 3 isTrain: False learn_residual: True loadSizeX: 640 loadSizeY: 360 max_dataset_size: inf model: test nThreads: 2 n_layers_D: 3 name: experiment_name ndf: 64 ngf: 64 no_dropout: False no_flip: False norm: instance ntest: inf output_nc: 3 phase: test resize_or_crop: resize_and_crop results_dir: ./results/ serial_batches: False which_direction: AtoB which_epoch: latest which_model_netD: basic which_model_netG: resnet_9blocks -------------- End ---------------- CustomDatasetDataLoader dataset [SingleImageDataset] was created /usr/local/lib/python2.7/dist-packages/torchvision/transforms/transforms.py:156: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. "please use transforms.Resize instead.") Traceback (most recent call last): File "test.py", line 21, in model = create_model(opt) File "/home/env114/Downloads/DeblurGAN-master/models/models.py", line 11, in create_model model.initialize(opt) File "/home/env114/Downloads/DeblurGAN-master/models/test_model.py", line 21, in initialize self.load_network(self.netG, 'G', which_epoch) File "/home/env114/Downloads/DeblurGAN-master/models/base_model.py", line 53, in load_network network.load_state_dict(torch.load(save_path)) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 331, in load_state_dict .format(name)) KeyError: 'unexpected key "model.0.weight" in state_dict'

If you could suggest how to fix this error it will be helpful. Thanks

dm0288 avatar Jan 16 '18 05:01 dm0288

This error occurs if the weights file does not match with the network. Do you have the correct latest_net_G model?

hrbspider avatar Jan 16 '18 13:01 hrbspider

Thanks for your response. No, I am using the latest_net_D model as that was the link provided by the readme file. From where can I get the correct latest_net_G model?

dm0288 avatar Jan 17 '18 04:01 dm0288

The author doesn't provide latest_net_G model .So, you should train it by yourself or request from the author.

hrbspider avatar Jan 17 '18 07:01 hrbspider

We provide the generator model, however, I have some problems with Dropbox so it was unavailable. I already updated the link to the model, please send me the message if you still can not download the weights or run the model

KupynOrest avatar Feb 06 '18 10:02 KupynOrest

Seems that the generator model still does not work @KupynOrest see #145

dvd42 avatar Aug 13 '19 16:08 dvd42