Home

Awesome

STGAN (CVPR 2019)

Tensorflow implementation of STGAN: A Unified Selective Transfer Network for Arbitrary Image Attribute Editing

<p align="center"> <img src="./pic/arch.jpg" width="95%"><br><center>Overall architecture of our STGAN. Taking the image above as an example, in the difference attribute vector <a href="http://latex.codecogs.com/gif.latex?\mathbf{att}_\mathit{diff}"><img src="http://latex.codecogs.com/gif.latex?\mathbf{att}_\mathit{diff}" alt="$\mathbf{att}_\mathit{diff}$"></a>, <a href="http://latex.codecogs.com/gif.latex?Young"><img src="http://latex.codecogs.com/gif.latex?Young" alt="$Young$"></a> is set to 1, <a href="http://latex.codecogs.com/gif.latex?Mouth\%20Open"><img src="http://latex.codecogs.com/gif.latex?Mouth\%20Open" alt="$Mouth\ Open$"></a> is set to -1, and others are set to zeros. The outputs of <a href="http://latex.codecogs.com/gif.latex?\mathit{D_{att}}"><img src="http://latex.codecogs.com/gif.latex?\mathit{D_{att}}" alt="$\mathit{D_{att}}$"></a> and <a href="http://latex.codecogs.com/gif.latex?\mathit{D_{adv}}"><img src="http://latex.codecogs.com/gif.latex?\mathit{D_{adv}}" alt="$\mathit{D_{adv}}$"></a> are the scalar <a href="http://latex.codecogs.com/gif.latex?\mathit{D_{adv}}(\mathit{G}(\mathbf{x},\mathbf{att}_\mathit{diff}))"><img src="http://latex.codecogs.com/gif.latex?\mathit{D_{adv}}(\mathit{G}(\mathbf{x},\mathbf{att}_\mathit{diff}))" alt="$\mathit{D_{adv}}(\mathit{G}(\mathbf{x}, \mathbf{att}_\mathit{diff}))$"></a> and the vector <a href="http://latex.codecogs.com/gif.latex?\mathit{D_{att}}(\mathit{G}(\mathbf{x},\mathbf{att}_\mathit{diff}))"><img src="http://latex.codecogs.com/gif.latex?\mathit{D_{att}}(\mathit{G}(\mathbf{x},\mathbf{att}_\mathit{diff}))" alt="$\mathit{D_{att}}(\mathit{G}(\mathbf{x}, \mathbf{att}_\mathit{diff}))$"></a>, respectively</center></p>

Exemplar Results

Preparation

Quick Start

Exemplar commands are listed here for a quick start.

Training

Testing

The arguments in [] are optional with a default value.

View Images

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.

NOTE:

AttGAN

Citation

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}
}

Acknowledgement

The code is built upon AttGAN, thanks for their excellent work!