PDillis / stylegan3-fun

Modifications of the official PyTorch implementation of StyleGAN3. Let's easily generate images and videos with StyleGAN2/2-ADA/3!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

any way to get the visualizer to support importing stylegan3-nada .pkl files?

nicolai256 opened this issue · comments

(https://github.com/rinongal/StyleGAN-nada/blob/StyleGAN3-NADA/stylegan3_nada.ipynb)
i'm making some tweaks to my stylegan3 network with this but it seems like i'm not able to import it to the visualizer
any way to get the visualizer to support these?
the generating of images in this repo is a little whacky but it's such a good tweak to stylegan, would be great if it worked :)
there is a fix for converting stylegan2-nada files to stylegan2 but not for 3 yet :/

https://github.com/eps696/stylegan2ada (this is the one for stylegan2 that converts the .pt files to .pkl files again)

Can you share more details on how the NADA models are saved? What about the conversion of SGAN2-NADA to SGAN2, can you share this fix or link? Might give it a go, but I have a lot of other things to do first on this repo, so if you leave here a better documentation of the problem, perhaps there's someone that might be able to fix it.

stylegan3-nada saving model (the maker of the code states that the generated pkl works with stylegan3)
rinongal/StyleGAN-nada#42 (comment)
stylegan3-nada official colab
https://colab.research.google.com/github/rinongal/stylegan-nada/blob/StyleGAN3-NADA/stylegan3_nada.ipynb
**stylegan3-nada customized colab (this is the one i use to load custom stylegans) **
https://colab.research.google.com/drive/1aVgDTl5iZMD785PStLZsykP1aiymyrk4?usp=sharing
the model i generated with stylegan-nada and the original model
https://drive.google.com/drive/folders/1UR5Ap7BvlW10dzL6VaI6zRgpazuHrnHa?usp=sharing
stylegan3-nada official jupyter notebook
https://github.com/rinongal/StyleGAN-nada/blob/StyleGAN3-NADA/stylegan3_nada.ipynb
stylegan2-nada to stylegan2 fix repo (Rosinality or StyleGAN2-NADA.pt to Nvidia SG2-ada-pytorch.pkl (conversion is all the way on the bottom of readme)
https://github.com/eps696/stylegan2ada

the thing is the stylegan3-nada can also export .pkl checkpoint files but they're only 86mb when the original pkl file is 287mb
it can export .pt files and those are 230mb so that's closer to the original,
i tried running it in the visualizer but it doesn't work, i also tried running it in the stylegan3 code and it gave this error
stylegan3 error =

Loading networks from "/content/drive/MyDrive/000150.pkl"...
Traceback (most recent call last):
  File "/content/drive/MyDrive/WIP/stylegan3/gen_images.py", line 143, in <module>
    generate_images() # pylint: disable=no-value-for-parameter
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/content/drive/MyDrive/WIP/stylegan3/gen_images.py", line 108, in generate_images
    G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore
  File "/content/drive/MyDrive/WIP/stylegan3/legacy.py", line 40, in load_network_pkl
    assert isinstance(data['G'], torch.nn.Module)
KeyError: 'G'

i got it working, i changed stylegan-fun/viz/renderer.py
line 20 import pickle
line 158 with dnnlib.util.open_url(pkl, verbose=False) as f:
data = pickle.load(f)
both types work now, default one and stylegan3-nada

It works beautifully! I might say that there's some test needed to be done, and the change you propose should actually be done inside dnnlib.util.open_url, so as to use it in any other part of the repo, but so far I was able to open your model in Windows 10 :)

image

All code should work with your converted StyleGAN-NADA models (4765f95). Check this is the case and reopen this if something breaks. Thanks!