genforce / sefa

[CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs
https://genforce.github.io/sefa/
MIT License
963 stars 108 forks source link

Compability issue for .pkl extension #13

Open cihatkapusuz opened 3 years ago

cihatkapusuz commented 3 years ago

We have a model stored as .pkl file which is trained on NVIDIA's StyleGAN. Since its extension is .pkl, and your structure asks for a .pth file, is there any way to convert our .pkl file to .pth file? Or is there any way to work on your system with a .pkl file?

wjkang619 commented 3 years ago

I have the same problem. I also have NVlab's 'Stylegan2-ADA', 'Stylegan2-ADA-PyTorch' models. (.pkl files)

9 suggested a method, but I didn't understand it.

I do not know how to load the parameters as NumPy.ndarray. I apologize for such a beginner's question.

ShenYujun commented 3 years ago

Any model weights (ideally) should be stored like a dictionary or a recursive dictionary. Some key-value pairs should be the parameter name-pre-trained weight pairs, where parameter name should be a string and pre-trained weight should be a tensor (pytorch or tensorflow version, both of which can be easily converted to numpy.ndarray). Please Google how to convert a pytorch (or tensorflow) tensor to a numpy.ndarray if you are really new to these two DL frameworks.

So, I would recommend first load the pkl file with ipython, and then check how the file is organized with print() function.