Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test.py RuntimeError: Error(s) in loading state_dict for UnetGenerator #812

Closed
Pavm96 opened this issue Oct 23, 2019 · 3 comments
Closed

Comments

@Pavm96
Copy link

Pavm96 commented Oct 23, 2019

I have a saved model, and when i run this command:

sudo python3 test.py --dataroot ./datasets/mydataset--model pix2pix --direction BtoA --name test10

I get this error:

dataset [AlignedDataset] was created
initialize network with normal
model [Pix2PixModel] was created
loading the model from ./checkpoints/test10/latest_net_G.pth
Traceback (most recent call last):
File "test.py", line 47, in
model.setup(opt) # regular setup: load and print networks; create schedulers
File "/usr/myec2/pix2pix/models/base_model.py", line 88, in setup
self.load_networks(load_suffix)
File "/usr/myec2/pix2pix/models/base_model.py", line 198, in load_networks
net.load_state_dict(state_dict)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 839, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for UnetGenerator:
Missing key(s) in state_dict: "model.model.1.model.2.weight", "model.model.1.model.2.bias", "model.model.1.model.2.running_mean", "model.model.1.model.2.running_var", "model.model.1.model.3.model.2.weight", "model.model.1.model.3.model.2.bias", "model.model.1.model.3.......

@Pavm96
Copy link
Author

Pavm96 commented Oct 23, 2019

Here are some of the options I used; may be relevant.

--model pix2pix --direction BtoA --batch_size 1 --norm instance --gpu_ids 0 --lr_policy linear --beta1 0.9 --lr 0.000001 --name test10 --gan_mode lsgan --init_type xavier

@junyanz
Copy link
Owner

junyanz commented Oct 23, 2019

Please also add --norm instance in your test code. The default one for pix2pix is --norm batch.

@Pavm96
Copy link
Author

Pavm96 commented Oct 23, 2019

Worked. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants