RuntimeError: Error(s) in loading state_dict for GFPGANv1: #71

Open
opened 2026-01-29 21:40:47 +00:00 by claunia · 7 comments
Owner

Originally created by @ntquyen11 on GitHub (Sep 17, 2021).

I train the model on my own dataset. However, when I inference image, the error happens and I don't know the reason for this
image

Originally created by @ntquyen11 on GitHub (Sep 17, 2021). I train the model on my own dataset. However, when I inference image, the error happens and I don't know the reason for this ![image](https://user-images.githubusercontent.com/73950718/133723268-5d4c4721-d9fa-433d-9c65-be91e8d505e0.png)
Author
Owner

@jcn16 commented on GitHub (Sep 21, 2021):

similar problem. The pretrained StyleGAN2 has size mismatch problem.

@jcn16 commented on GitHub (Sep 21, 2021): similar problem. The pretrained StyleGAN2 has size mismatch problem.
Author
Owner

@jcn16 commented on GitHub (Sep 21, 2021):

you can extract pretrained StyleGAN2 from the given checkpoint, which works for me.

@jcn16 commented on GitHub (Sep 21, 2021): you can extract pretrained StyleGAN2 from the given checkpoint, which works for me.
Author
Owner

@ntquyen11 commented on GitHub (Sep 22, 2021):

you can extract pretrained StyleGAN2 from the given checkpoint, which works for me.

Thanks for your response. I fixed this p

@ntquyen11 commented on GitHub (Sep 22, 2021): > you can extract pretrained StyleGAN2 from the given checkpoint, which works for me. Thanks for your response. I fixed this p
Author
Owner

@xinntao commented on GitHub (Sep 23, 2021):

It seems that the loaded model has a mismatched size from your configuration.

You may need to update the configuration.
If you need the corresponding pre-trained model, please let me know, I will upload it.

@xinntao commented on GitHub (Sep 23, 2021): It seems that the loaded model has a mismatched size from your configuration. You may need to update the configuration. If you need the corresponding pre-trained model, please let me know, I will upload it.
Author
Owner

@jcn16 commented on GitHub (Sep 23, 2021):

To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different.
Simply changing the keys can solve the mismatch problem

@jcn16 commented on GitHub (Sep 23, 2021): To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different. Simply changing the keys can solve the mismatch problem
Author
Owner

@xinntao commented on GitHub (Sep 23, 2021):

To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different.
Simply changing the keys can solve the mismatch problem

GFPGANCleanv1-NoCE-C2.pth uses a different network from StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth.
We have not upload the whole training process and pre-trained models for GFPGANCleanv1-NoCE-C2.pth

@xinntao commented on GitHub (Sep 23, 2021): > To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different. > Simply changing the keys can solve the mismatch problem GFPGANCleanv1-NoCE-C2.pth uses a different network from StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. We have not upload the whole training process and pre-trained models for GFPGANCleanv1-NoCE-C2.pth
Author
Owner

@ntquyen11 commented on GitHub (Sep 27, 2021):

To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different.
Simply changing the keys can solve the mismatch problem

GFPGANCleanv1-NoCE-C2.pth uses a different network from StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth.
We have not upload the whole training process and pre-trained models for GFPGANCleanv1-NoCE-C2.pth

yup. I have to change channel = 1 instead of channel = 2 and arch = None when using my model. Thanks for your response

@ntquyen11 commented on GitHub (Sep 27, 2021): > > To kown the reason, you can print the dict keys of GFPGANCleanv1-NoCE-C2.pth and StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. The names of styleGAN mlp layer are different. > > Simply changing the keys can solve the mismatch problem > > GFPGANCleanv1-NoCE-C2.pth uses a different network from StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth. > We have not upload the whole training process and pre-trained models for GFPGANCleanv1-NoCE-C2.pth yup. I have to change channel = 1 instead of channel = 2 and arch = None when using my model. Thanks for your response
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#71