Tensorflow implementation of STGAN: A Unified Selective Transfer Network for Arbitrary Image Attribute Editing
See results.md for more results
Facial attribute editing results
Image translation results
Prerequisites
Dataset
pre-trained model
Exemplar commands are listed here for a quick start.
for 128x128 images
python train.py --experiment_name 128
for 384x384 images (please prepare data according to HD-CelebA)
python train.py --experiment_name 384 --img_size 384 --enc_dim 48 --dec_dim 48 --dis_dim 48 --dis_fc_dim 512 --n_sample 24 --use_cropped_img
Example of testing single attribute
python test.py --experiment_name 128 [--test_int 1.0]
Example of testing multiple attributes
python test.py --experiment_name 128 --test_atts Pale_Skin Male [--test_ints 1.0 1.0]
Example of attribute intensity control
python test.py --experiment_name 128 --test_slide --test_att Male [--test_int_min -1.0 --test_int_max 1.0 --n_slide 10]
The arguments in []
are optional with a default value.
You can use show_image.py
to show the generated images, the code has been tested on Windows 10 and Ubuntu 16.04 (python 3.6). If you want to change the width of the buttons in the bottom, you can change width
parameter in the 160th line. the '+++' and '---' on the button indicate that the above image is modified to 'add' or 'remove' the attribute. Note that you should specify the path of the attribute file (list_attr_celeba.txt
) of CelebA in the 82nd line.
--dataroot DATAROOT
;--gpu GPU
, e.g., --gpu 0
;--img num
(e.g., --img 182638
, --img 200000 200001 200002
), where the number should be no larger than 202599 and is suggested to be no smaller than 182638 as our test set starts at 182638.png.--label
: 'diff'(default) for difference attribute vector, 'target' for target attribute vector--stu_norm
: 'none'(default), 'bn' or 'in' for adding no/batch/instance normalization in STUs--mode
: 'wgan'(default), 'lsgan' or 'dcgan' for differenct GAN lossesTrain with AttGAN model by
python train.py --experiment_name attgan_128 --use_stu false --shortcut_layers 1 --inject_layers 1
If you find STGAN useful in your research work, please consider citing:
@InProceedings{liu2019stgan,
title={STGAN: A Unified Selective Transfer Network for Arbitrary Image Attribute Editing},
author={Liu, Ming and Ding, Yukang and Xia, Min and Liu, Xiao and Ding, Errui and Zuo, Wangmeng and Wen, Shilei},
booktitle={IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2019}
}
The code is built upon AttGAN, thanks for their excellent work!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。