isno0907 / localbasis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do Not Escape From the Manifold: Discovering the Local Coordinates on the Latent Space of GANs

Python 3.7 PyTorch 1.3 teaser teaser

Figure 1: Semantic factorization through constrained traversal. The examples are discovered by constraining the latent traversal to a subset of the layers. The subset is chosen among the coarse, middle, and fine layers defined by StyleGAN. It can be seen that semantics are well factorized.

Setup

  1. Change environment.yml CUDA version to yours [CUDA version must be 10.x]
  2. Create environment: conda create -n local_basis python=3.7
  3. Activate environment: conda activate local_basis
  4. Install dependencies: conda env update -f environment.yml --prune
Optional
4. `cd models/stylegan2/stylegan2-pytorch/op`
5. `python setup.py install`
6. Test: `python -c "import torch; import upfirdn2d_op; import fused; print('OK')"`

Usage

All code is implemented in jupyter notebook.

Reproducibility

StyleGAN

  1. Install TensorFlow: conda install tensorflow-gpu=1.*.
  2. Modify methods __init__(), load_model() in models/wrappers.py under class StyleGAN.

StyleGAN2

  1. Follow the instructions in models/stylegan2/stylegan2-pytorch/README.md. Make sure to use the fork in this specific folder when converting the weights for compatibility reasons.
  2. Save the converted checkpoint as checkpoints/stylegan2/<dataset>_<resolution>.pt.
  3. Modify methods __init__(), download_checkpoint() in models/wrappers.py under class StyleGAN2.

Citation

@article{choi2021not,
  title={Do not escape from the manifold: Discovering the local coordinates on the latent space of GANs},
  author={Choi, Jaewoong and Lee, Junho and Yoon, Changyeon and Park, Jung Ho and Hwang, Geonho and Kang, Myungjoo},
  journal={arXiv preprint arXiv:2106.06959},
  year={2021}
}

License

The files models/wrappers.py, notebooks/ganspace_utils.py and notebooks/notebook_utils.py are a derivative of the GANSpace, and are provided under the Apache 2.0 license.
The directory netdissect is a derivative of the GAN Dissection project, and is provided under the MIT license.
The directories models/biggan and models/stylegan2 are provided under the MIT license.

About


Languages

Language:Jupyter Notebook 97.9%Language:Python 1.9%Language:HTML 0.1%Language:Cuda 0.1%Language:C 0.0%Language:C++ 0.0%Language:Shell 0.0%