genforce / interfacegan

[CVPR 2020] Interpreting the Latent Space of GANs for Semantic Face Editing
https://genforce.github.io/interfacegan/
MIT License
1.51k stars 281 forks source link

Issues converting custom pggan models #10

Closed AndrewMakar closed 5 years ago

AndrewMakar commented 5 years ago

It seems that for pggan, state dictionaries for the model trained by paper authors (file karras2018iclr-celebahq-1024x1024.pkl) and custom models that are trained by their released code are different. You can check the differences here: https://www.diffchecker.com/0hFYlK82.

Unfortunately I was unable to tweak your code so that it would convert my trained model correctly.

Did you try converting custom trained model using pggan code? If so, could you please provide a model you trained that worked for you other than the one provided by pggan authors?

ShenYujun commented 5 years ago

Sorry, but we didn't test on custom models. However, according to the diff file, you can simply change all Conv0 to Conv0_up in file models/pggan_generator_model.py. And swap the last two channels of weight parameter of Conv0_up layer when converting models (if needed).

AndrewMakar commented 5 years ago

Yes, I tried those changes but they didn't help. Converted model generates some random stuff instead of a well-formed images.

If you have some time to play around with that stuff I can email you a custom model that I was trying to convert.

ShenYujun commented 5 years ago

Sure, I would like to help. Please also provide the training and inference code if possible. I want to make sure I use your model correctly.

c1a1o1 commented 5 years ago

I have the same question!

ShenYujun commented 5 years ago

@AndrewMakar Thanks for pointing out this issue. I have done some tests on your model and successfully converted it. Solutions are as follows:

  1. The officially released model does not use fused_scale, which means to combine conv2d and upsample2d together as conv2d_transpose. However, the official implementation uses fused_scale as default. I have already update the repo which now well supports fused_scale.

  2. Your model hasn't been finished. Or say, the progressive progress is supposed to train until 1024x1024 resolution yet stops at 256x256 resolution. Actually, the tensorflow model employs a variable lod to handle this case. Accordingly, I have also involved this variable to make this repo more robust.

Now, please do experiments with the latest version. Hopefully it helps.

AndrewMakar commented 5 years ago

Works like a charm. Thank you so much!