harskish / ganspace

Discovering Interpretable GAN Controls [NeurIPS 2020]
Apache License 2.0
1.78k stars 264 forks source link

Ganspace not compatible with StyleGan2-ADA-PyTorch models #37

Open pbizimis opened 3 years ago

pbizimis commented 3 years ago

Hey, I tried setting up Ganspace with StyleGan2-ADA-PyTorch models but it seems not possible without modifying code. Most errors show that the module torch_utils is necessary to load the model pkl files.

    magic_number = pickle_module.load(f, **pickle_load_args)
ModuleNotFoundError: No module named 'torch_utils'

I also was not able to convert weights. Any ideas on how to make ganspace working with the new model files? Thanks

harskish commented 3 years ago

Since StyleGan2-ADA-PyTorch is a pytorch codebase, it would probably be easiest to add it alongside the other models (in models/wrappers.py) as an alternative StyleGAN2 implementation. It might also be possible to convert StyleGan2-ADA-PyTorch pickles to the format expected by using rosinality's repo (https://github.com/rosinality/stylegan2-pytorch), but that seems more error-prone.

mctrinkle commented 3 years ago

I agree StyleGan2-ADA-PyTorch implementation should be added to wrappers.py and I have tried this and haven't had time to finish it. However, I believe rosinality's repo (https://github.com/rosinality/stylegan2-pytorch) is meant to convert from tf weights and will not work.

pbizimis commented 3 years ago

While I was looking for a solution, I found the closed-form factorization implementation in rosinality's repo (https://github.com/rosinality/stylegan2-pytorch). I managed to get it working with the new StyleGan2-ADA-PyTorch models. You can find it here https://github.com/pbizimis/stylegan2-ada-pytorch. Closed-form factorization can be an alternative for Ganspace (https://arxiv.org/pdf/2007.06600.pdf).

tocantrell commented 2 years ago

For anyone that stumbles on this thread like I did in trying to find a solution for latent space manipulation with StyleGan2-ADA: while it is great work that led me to my current solution, pbizimis's code does not alter the w-space as I expected it to. But after creating my own working solution based on it, I saw that someone already published the same code improved to use w-space: https://github.com/dvschultz/stylegan2-ada-pytorch I would just caution that lines 38-40 of apply_factor.py may have better performance on GPU without the 'force_fp32=True'.

clairesquires99 commented 2 years ago

I agree StyleGan2-ADA-PyTorch implementation should be added to wrappers.py and I have tried this and haven't had time to finish it. However, I believe rosinality's repo (https://github.com/rosinality/stylegan2-pytorch) is meant to convert from tf weights and will not work.

Since this was a while ago, I though it would be worth checking wether the StyleGan2-ADA-PyTorch implementation had still not been added to wrappers.py?

McFredward commented 2 years ago

I've implemented StyleGAN2-ada support (along with other changes) in my fork:

https://github.com/McFredward/ganspace

f3ax commented 1 year ago

I've implemented StyleGAN2-ada support (along with other changes) in my fork:

https://github.com/McFredward/ganspace

@McFredward Hello, I know it's been a long time since you posted this fork, but I am trying to use it and I am having a few issues if you could please provide any explanation or guidance that would be super helpful.