GANalyzer: Analysis and Manipulation of GANs Latent Space for Controllable Face Synthesis

Introduction

Recent advancements in Generative Adversarial Networks (GANs) have significantly improved face synthesis quality, yet the lack of transparency on the mapping of input latent vectors to synthesized images limits their application. To address this issue, we propose GANalyzer, a framework for the interpretation, and manipulation of the latent space of well-trained GANs. GANalyzer can manipulate latent vectors for single, compound, and disentangled modifications of Facial Emotion, Age, Gender, and Racial Prototypicality. We utilized GANalyzer for two main applications: Facial Attribute Editing (FAE) and Feature-Based Synthesis (FBS). For FAE, GANalyzer modifies one or more facial attributes while preserving the identity of the face. In contrast, for FBS, GANalyzer manipulates a randomly sampled latent vector such that its corresponding image has a set of specified facial attributes. Our extensive experimentation demonstrates the performance of the GANalyzer in both FAE and FBS tasks. Furthermore, building upon the capability of GANalyzer in FBS, we create and release a balanced photo-realistic human face dataset with 23 subsets containing the least appearing combinations of facial attributes. Our dataset contributes various deep learning applications including facial expression, age, race, and gender recognition. Upon publication, both the dataset and code will be publicly available.

Qualitative Results Evaluation

Explore the performance of GANalyzer for facial attribute editing and intensity-based modification.

Facial Attribute Editing:

Sample All

Intensity-Based Attribute Editing:

Intensity-based

Creating Environment

        
$ conda env create -f environment.yml
$ conda activate ganalyzer
$ pip install -r requirements.txt
        
    

Facial Attribute Editing

To create a modification task, use test.py->create_single_FAE_task(). Default tasks are provided, and you can modify each task as explained in the paper.

        
fae_tasks = [
    {'tn': 'ANGRY', 'alpha': 2.5, 'beta': 1.0},
    {'tn': 'BLACK', 'alpha': 2.0, 'beta': 1.0},
    {'tn': 'FEMALE', 'alpha': 3.5, 'beta': 1.0},
    {'tn': 'MALE', 'alpha': 3.0, 'beta': 1.0},
    {'tn': 'OLD', 'alpha': 4.0
    
    

After creating tasks, pass each task to test.py->modify_noise() to modify arbitrary input latent vectors.

Feature-based Synthesis

Create a modification task using test.py->create_single_FB_task(). Default tasks are provided, and you can modify each task as explained in the paper.

        
fb_tasks = [
    {'tn': 'ANGRY', 'alpha': 1.0, 'beta': 0.25},
    {'tn': 'BLACK
    {'tn': 'BLACK', 'alpha': 1.0, 'beta': 0.25},
{'tn': 'FEMALE', 'alpha': 1.0, 'beta': 0.25},
{'tn': 'MALE', 'alpha': 1.0, 'beta': 0.25},
{'tn': 'OLD', 'alpha': 1.0, 'beta': 0.25},
{'tn': 'YOUNG', 'alpha': 1.0, 'beta': 0.25},
]

After creating tasks, pass each task to test.py->modify_noise() to modify arbitrary input latent vectors.

Image Generation

GANalyzer focuses on latent space modification, and image synthesis is performed using StylGAN3. The image generation function in test.py->generate_images() is provided by the StyleGAN3 repo.

        
! IF YOU USE THIS FUNCTION, YOU NEED TO FOLLOW StyleGAN3 Licence:
[StyleGAN3 License](https://github.com/NVlabs/stylegan3/blob/main/LICENSE.txt)
        
    

Download ffhq.pkl following the documentation provided by the StyleGAN3 repo.

Reference:

        
@misc{https://doi.org/10.48550/arxiv.2302.00908,
  doi = {10.48550/ARXIV.2302.00908},
  url = {https://arxiv.org/abs/2302.00908},
  author = {Fard, Ali Pourramezan and Mahoor, Mohammad H. and Lamer, Sarah Ariel and Sweeny, Timothy},
  title = {GANalyzer: Analysis and Manipulation of GANs Latent Space for Controllable Face Synthesis},
  publisher = {arXiv},
  year = {2023},
}
        
    

Synthesized Samples

Facial Expression: Anger

ANGRY.gif

Race

RACE

Gender: Female

FEMALE.gif

Gender: Male

MALE.gif

Age: Old

OLD.gif

Age: Young

YOUNG.gif