ganspace icon indicating copy to clipboard operation
ganspace copied to clipboard

Ganspace not compatible with StyleGan2-ADA-PyTorch models

Open pbizimis opened this issue 3 years ago • 7 comments

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

pbizimis avatar Mar 14 '21 15:03 pbizimis

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.

harskish avatar Mar 16 '21 08:03 harskish

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.

mctrinkle avatar Mar 16 '21 16:03 mctrinkle

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).

pbizimis avatar Mar 18 '21 18:03 pbizimis

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'.

tocantrell avatar Sep 12 '21 01:09 tocantrell

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?

clairesquires99 avatar Jan 24 '22 12:01 clairesquires99

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

https://github.com/McFredward/ganspace

McFredward avatar Jun 10 '22 14:06 McFredward

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.

f3ax avatar Apr 13 '23 19:04 f3ax