Generative Adversarial Network with Spatial Attention for Face Attribute Editing

Gang Zhang, Meina Kan, Shiguang Shan, Xilin Chen

Abstract

SaGAN (Spatial Attention GAN) introduces a "where-to-edit" mechanism into face attribute manipulation. By decoupling the editing process into an Attribute Manipulation Network (the "how") and a Spatial Attention Network (the "where"), the model ensures that changes like adding eyeglasses or a smile only affect relevant pixels while leaving the rest of the face perfectly intact.

Introduction

Face attribute editing—tasks like changing hair color, adding a beard, or altering an expression—has seen massive leaps thanks to Generative Adversarial Networks (GANs). However, a persistent challenge remains: most GANs operate on the entire image globally. When a standard GAN is tasked with adding eyeglasses, it might subtly change skin texture, background, or eye color because it lacks a mechanism to isolate the specific region that needs changing. While previous attempts used sparse residuals to limit changes, they often struggled to localize complex attributes accurately.

Localization of target attributes like eyeglasses and smiles for precise spatial editing.

The authors of SaGAN aim to solve this by explicitly teaching the network to focus its attention only on the regions that matter for a specific attribute, preserving the integrity of the original image elsewhere.

Methodology

The core innovation of SaGAN is its generator architecture, which is split into two specialized sub-networks:

  1. Attribute Manipulation Network (AMN): This network acts as the "artist," taking the input image and the target attribute to generate what the entire edited image might look like.
  2. Spatial Attention Network (SAN): This network acts as the "stencil," predicting a probability mask (values between 0 and 1) that identifies which pixels are relevant to the attribute being edited. For eyeglasses, the mask focuses on the bridge of the nose and eyes; for a smile, it focuses on the mouth and cheeks.
The Spatial Attention Network (SAN) generates probability masks to isolate attribute-relevant regions from the original image.

The Fusion Mechanism: The final output image ($\hat{I}$) is a weighted blend of the edited image ($I_a$) and the original image ($I$), governed by the attention mask ($b$): $$\hat{I} = I_a \cdot b + I \cdot (1 - b)$$ This formula ensures that if the mask is 0 (irrelevant region), the original pixels are preserved perfectly. If the mask is 1, the edited pixels are used. The model is trained using a standard Discriminator alongside Dual Reconstruction and Identity Reconstruction losses to maintain consistency.

Experimental Setup

The researchers evaluated SaGAN using two primary benchmarks:

  • CelebA: A massive dataset of over 202,000 celebrity face images annotated with 40 binary attributes, serving as the primary training and testing ground.
  • LFW (Labeled Faces in the Wild): Used specifically to test the generalization of the model on unconstrained real-world images.

Results and Discussion

SaGAN consistently outperformed state-of-the-art models like CycleGAN and StarGAN in preserving attribute-irrelevant details. While other models often introduced blurring or color shifts in the background, SaGAN kept them identical to the source.

Key insights include:

  • Decoupling "What" from "Where": By delegating preservation to the SAN, the AMN can focus entirely on the quality of the edit.
  • Adaptive Masking: The SAN learns that different attributes require different "spreads" of attention (e.g., a larger mask for a smile vs. a tighter mask for eyeglasses).
  • Data Augmentation: SaGAN can generate synthetic training data for face recognition, improving model robustness by creating variations of the same person with different attributes.

Quantitatively, face recognition models trained with SaGAN-augmented data showed improved accuracy, proving that the edits maintain the underlying identity of the subject.

Conclusion

While SaGAN excels at localized editing, it currently handles one attribute at a time, unlike multi-attribute models like StarGAN. Future work will focus on simultaneous multi-attribute editing and addressing attribute correlations (e.g., ensuring that removing a beard doesn't inadvertently feminize a face due to dataset biases).

Summary updated

BibTeX
@inproceedings{zhang2018generative,
  author = {Gang Zhang and Meina Kan and Shiguang Shan and Xilin Chen},
  title = {{Generative Adversarial Network with Spatial Attention for Face Attribute Editing}},
  booktitle = {European Conference on Computer Vision},
  year = {2018},
  doi = {10.1007/978-3-030-01231-1\_26},
}
Figure