NOTE : This is work based on publishe paper found here.
Note: you need a Nvidia GPU to run the processing. Only editor API with pre-computed latent vectors is available with CPU.
Clone this repository and pull the models required from postprocessing via LFS:
git clone [email protected]:valentingol/gan-face-editing.git
cd gan-face-editing
git lfs pull
Then, create a new virtual environment and install all the required packages:
pip install -e .
pip install -r requirements.txt
# configs/exp/
data_dir: data/my_dataset_name
Note that if you not used the characteristics in the image, you can name the translation vectors as you want.
Important: To use the semantic segmentation mixup, the algorithm should understand the part of the face you want to modify (and the part of the image you want to preserve from the original image). To do so, you need to add a particular prefix for the translation vectors: for instance for eyes change, you need to use the prefix 'N'. For instance N_0
is a valid translation that will only edit the eyes. The table of prefix is:
Part to modify | Prefix |
---|---|
All the face | A, Ch, Se or Sk |
Hair | B, Hc or Hs |
Nose | Pn |
Eyes | Bn or N |
Just under eyes | Be |
Lips | Bp |
If you don't use one of the prefix above, no segmentation mixup will be applied. You can use the prefix you want for custom transformations. More intuitive prefix will be available later (e.g 'eyes' for eyes, 'face' for all the face ...).
🚧
To retrain the GAN you need to install horovod (Mac or Linux only).
🚧