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

Errror loading pretrained model #36

Open
ipereira-uib opened this issue May 19, 2021 · 5 comments
Open

Errror loading pretrained model #36

ipereira-uib opened this issue May 19, 2021 · 5 comments

Comments

@ipereira-uib
Copy link

Where i try to test the model with a diferents weights of netG_epoch_4_1.pth It shows me the following error:
Traceback (most recent call last):
File "/content/drive/MyDrive/iSeeBetter/utils.py", line 19, in loadPreTrainedModel
model.load_state_dict(state_dict)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 845, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Net:
Missing key(s) in state_dict: "feat0.conv.weight", "feat0.conv.bias", "feat0.act.weight", "feat1.conv.weight", "feat1.conv.bias", "feat1.act.weight", "DBPN.feat1.conv.weight", "DBPN.feat1.conv.bias", "DBPN.feat1.act.weight", "DBPN.up1.up_conv1.deconv.weight", "DBPN.up1.up_conv1.deconv.bias", "DBPN.up1.up_conv1.act.weight", "DBPN.up1.up_conv2.conv.weight", "DBPN.up1.up_conv2.conv.bias", "DBPN.up1.up_conv2.act.weight", "DBPN.up1.up_conv3.deconv.weight", ...

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "iSeeBetterTest.py", line 213, in
eval()
File "iSeeBetterTest.py", line 95, in eval
utils.loadPreTrainedModel(gpuMode=args.gpu_mode, model=model, modelPath=modelPath)
File "/content/drive/MyDrive/iSeeBetter/utils.py", line 32, in loadPreTrainedModel
model.load_state_dict(new_state_dict)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 845, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Net:
Missing key(s) in state_dict: "feat0.conv.weight", "feat0.conv.bias", "feat0.act.weight", "feat1.conv.weight", "feat1.conv.bias", "feat1.act.weight", "DBPN.feat1.conv.weight", "DBPN.feat1.conv.bias", "DBPN.feat1.act.weight", "DBPN.up1.up_conv1.deconv.weight", "DBPN.up1.up_conv1.deconv.bias", "DBPN.up1.up_conv1.act.weight", "DBPN.up1.up_conv2.conv.weight", "DBPN.up1.up_conv2.conv.bias", "DBPN.up1.up_conv2.act.weight", "DBPN.up1.up_conv3.deconv.weight", "DBPN.up1.up_conv3.deconv.bias", "DBPN.up1.up_conv3.act.weight", "DBPN.down1.down_conv1.conv.weight", "DBPN.down1.down_conv1.conv.bias", "DBPN.down1.down_conv1.act.weight", "DBPN.down1.down_conv2.deconv.weight", "DBPN.down1.down_conv2.deconv.bias", "DBPN.down1.down_conv2.act.weight", "DBPN.down1.down_conv3.conv.weight", ...

@BLCKEAGLE4
Copy link

I'm facing the same issue.
In utils.py if you replace model.load_state_dict(new_state_dict) with
model.load_state_dict(new_state_dict, strict = False) then it seems that might work, but this solution will cause other problems to the results. Did you find other solution?

@BLCKEAGLE4
Copy link

@ipereira-uib Did you solve it? I have the same problem

@ipereira-uib
Copy link
Author

I don't solve it. If I find the problem I will post it here. :(

@BLCKEAGLE4
Copy link

I'm facing the same issue only when I try to load the pre-trained RBPN_4x model in training.
Ok thank you

@CybotDNA
Copy link

CybotDNA commented Oct 20, 2021

I have the same error.
What kind of system do you use?
I use Windows 11, anaconda and a RTX3060

Maybe it is a pyflow issue with windows?

[pip3] numpy==1.17.0
[pip3] torch==1.9.1+cu111
[pip3] torchaudio==0.9.1
[pip3] torchvision==0.10.1+cu111
[conda] _pytorch_select 0.1 cpu_0
[conda] blas 1.0 mkl
[conda] libmklml 2019.0.5 haa95532_0
[conda] mkl 2019.4 245
[conda] mkl-service 2.3.0 py37h196d8e1_0
[conda] mkl_fft 1.3.0 py37h46781fe_0
[conda] mkl_random 1.0.4 py37h343c172_0
[conda] numpy 1.17.0 py37h19fb1c0_0
[conda] numpy-base 1.17.0 py37hc3f5095_0
[conda] torch 1.9.1+cu111 pypi_0 pypi
[conda] torchaudio 0.9.1 pypi_0 pypi
[conda] torchvision 0.10.1+cu111 pypi_0 pypi

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

3 participants