Authors official implementation of the Unsupervised Discovery of Interpretable Directions in the GAN Latent Space (ICML 2020).
This code explores interpretable latent space directions of a pretrained GAN.
Our approach scheme: latent deformator A aims to produce shifts that are easy to distinguish for the reconstructor R
Here are several examples for Spectal Norm GAN (MNIST & Anime Faces), ProgGAN (CelebA-HQ) and BigGAN (ILSVRC):
python 3.6 or later
jupyter (for visualization)
torch>=1.4
torchvision
tqdm
tensorboardX
see requirement.txt
for exact authors environment.
Here is a minimal example of latent rectification run command:
python run_train.py \
--gan_type BigGAN \
--gan_weights models/pretrained/generators/BigGAN/G_ema.pth \
--deformator ortho \
--out rectification_results_dir
this script will save the latent space directions stored in LatentDeformator
module weights.
It also saves images charts with latent directions examples.
gan_type
specifies the generator model.
Note that you can pass as an argument any parameter of Params
class defined in trainer.py
Run evaluation.ipynb
notebook for the discovered directions inspection.
Run python download.py
to download all pretrained generators and latent directions.
We also add human_annotation.txt
file with annotation of some of directions.
The pretrained models are the unchanged copies from the following sources:
100_celeb_hq_network-snapshot-010403.pth
from https://github.com/ptrblck/prog_gans_pytorch_inference
G_ema.pth
from https://github.com/ajbrock/BigGAN-PyTorch and stylegan2-ffhq-config-f.pkl
https://github.com/NVlabs/stylegan2
converted with https://github.com/rosinality/stylegan2-pytorch
Here are some examples of generated images manipulation by moving along discovered directions:
StyleGAN2 - FFHQ - opened eyes
BigBiGAN - ImageNet - light direction
BigGAN - ImageNet - rotation
BigGAN code and weights are based on the authors implementation: https://github.com/ajbrock/BigGAN-PyTorch
ProgGAN code and weights are based on: https://github.com/ptrblck/prog_gans_pytorch_inference
U-net segmentation model code is based on: https://github.com/milesial/Pytorch-UNet