New
AttGAN
TIP Nov. 2019, arXiv Nov. 2017
TensorFlow implementation of AttGAN: Facial Attribute Editing by Only Changing What You Want
Other implementations of AttGAN
AttGAN-PyTorch by Yu-Jing Lin
AttGAN-PaddlePaddle by ceci3 and zhumanyu (AttGAN is one of the official reproduced models of PaddlePaddle)
Closely related works
An excellent work built upon our code - STGAN (CVPR 2019) by Ming Liu
Changing-the-Memorability (CVPR 2019 MBCCV Workshop) by acecreamu
Fashion-AttGAN (CVPR 2019 FSS-USAD Workshop) by Qing Ping
An unofficial demo video of AttGAN by 王一凡
See results.md for more results, we try higher resolution and more attributes (all 40 attributes!!!)
Inverting 13 attributes respectively
from left to right: Input, Reconstruction, Bald, Bangs, Black_Hair, Blond_Hair, Brown_Hair, Bushy_Eyebrows, Eyeglasses, Male, Mouth_Slightly_Open, Mustache, No_Beard, Pale_Skin, Young
Environment
Python 3.6
TensorFlow 1.15
OpenCV, scikit-image, tqdm, oyaml
we recommend Anaconda or Miniconda, then you can create the AttGAN environment with commands below
conda create -n AttGAN python=3.6
source activate AttGAN
conda install -c anaconda tensorflow-gpu=1.15
conda install -c anaconda opencv
conda install -c anaconda scikit-image
conda install -c anaconda tqdm
conda install -c conda-forge oyaml
Data Preparation
CelebA-unaligned (10.2GB, higher quality than the aligned data)
download the dataset
img_celeba.7z (move to ./data/img_celeba/img_celeba.7z): Google Drive or Baidu Netdisk
annotations.zip (move to ./data/img_celeba/annotations.zip): Google Drive
unzip and process the data
7z x ./data/img_celeba/img_celeba.7z/img_celeba.7z.001 -o./data/img_celeba/
unzip ./data/img_celeba/annotations.zip -d ./data/img_celeba/
python ./scripts/align.py
Run AttGAN
NOTICE: if you create a new conda environment, remember to activate it before any command
source activate AttGAN
training (see examples.md for more training commands)
CUDA_VISIBLE_DEVICES=0 \
python train.py \
--load_size 143 \
--crop_size 128 \
--model model_128 \
--experiment_name AttGAN_128
testing
single attribute editing (inversion)
CUDA_VISIBLE_DEVICES=0 \
python test.py \
--experiment_name AttGAN_128
multiple attribute editing (inversion) example
CUDA_VISIBLE_DEVICES=0 \
python test_multi.py \
--test_att_names Bushy_Eyebrows Pale_Skin \
--experiment_name AttGAN_128
attribute sliding example
CUDA_VISIBLE_DEVICES=0 \
python test_slide.py \
--test_att_name Pale_Skin \
--test_int_min -2 \
--test_int_max 2 \
--test_int_step 0.5 \
--experiment_name AttGAN_128
loss visualization
CUDA_VISIBLE_DEVICES='' \
tensorboard \
--logdir ./output/AttGAN_128/summaries \
--port 6006
convert trained model to .pb file
python to_pb.py --experiment_name AttGAN_128
Using Trained Weights
alternative trained weights (move to ./output/*.zip)
AttGAN_128.zip (987.5MB)
AttGAN_128_generator_only.zip (161.5MB)
AttGAN_384_generator_only.zip (91.1MB)
unzip the file (AttGAN_128.zip for example)
unzip ./output/AttGAN_128.zip -d ./output/
testing (see above)
Example for Custom Dataset
If you find AttGAN useful in your research work, please consider citing:
@ARTICLE{8718508,
author={Z. {He} and W. {Zuo} and M. {Kan} and S. {Shan} and X. {Chen}},
journal={IEEE Transactions on Image Processing},
title={AttGAN: Facial Attribute Editing by Only Changing What You Want},
year={2019},
volume={28},
number={11},
pages={5464-5478},
keywords={Face;Facial features;Task analysis;Decoding;Image reconstruction;Hair;Gallium nitride;Facial attribute editing;attribute style manipulation;adversarial learning},
doi={10.1109/TIP.2019.2916751},
ISSN={1057-7149},
month={Nov},}