Discovering Interpretable Latent Space Directions of GANs Beyond Binary Attributes.
Huiting Yang, Liangyu Chai, Qiang Wen, Shuang Zhao, Zixun Sun, Shengfeng He
In CVPR 2021
git clone https://github.com/BERYLSHEEP/AdvStyle.git
models/pretrain/pytorch
The following commands are examples of testing the learned direction:
# stylegan ffhq
python new_demo.py manipulate_test supermodel \
--gan_model stylegan_ffhq --resolution 1024 --latent_type z
# stylegan anime
python new_demo.py manipulate_test maruko \
--gan_model stylegan_anime --resolution 512 --latent_type z
if you want to manipulate multi attributes simultaneously, you can list all the attributes on the command as follow:
# multi attribute manipulation
python new_demo.py manipulate_test blonde,open_mouth \
--gan_model stylegan_anime --resolution 512 --latent_type z
If you want to specific the manipulated latent code, you can set the --noise_path option:
# specific latent code
python new_demo.py manipulate_test maruko \
--gan_model stylegan_anime --resolution 512 --latent_type z \
--noise_path ./noise/maruko/2.npy
Results are saved to result/{attribute}
The attribute names are the file names in the boundaries
directory.
Prerequisites: Flask
pip install flask
pip install --upgrade flask_nav
pip install --upgrade flask_bootstrap
Running
# only for stylegan_anime
# the input latent code is belong to latent space z [1, 512]
python app.py --latent_code noise/maruko/16.npy --composing_type z
# the input latent code is belong to latent space w+ [1, 16, 512]
python app.py --latent_code noise/38_w+.npy --composint_type w+
Instructions
Edit
Button for "Pink Hair", then move the corresponding toolbar to the desired step.Edit
Button for "Open Mouth", then move the corresponding toolbar to the desired step.If you use this code for your research, please cite our paper:
@InProceedings{Yang_2021_CVPR,
author = {Yang, Huiting and Chai, Liangyu and Wen, Qiang and Zhao, Shuang and Sun, Zixun and He, Shengfeng},
title = {Discovering Interpretable Latent Space Directions of GANs Beyond Binary Attributes},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2021},
pages = {12177-12185}
}