StyleSwap: Style-Based Generator Empowers Robust Face Swapping

Zhiliang Xu, Hang Zhou, Zhibin Hong, Ziwei Liu, Jiaming Liu, Zhizhi Guo, Junyu Han, Jingtuo Liu, Errui Ding, Jingdong Wang

Abstract

Face swapping requires a delicate balance between preserving the source identity and maintaining the target's attributes, such as pose, expression, and lighting. We present StyleSwap, a high-fidelity framework that leverages the representational power of StyleGAN2. By treating identity as a global "style" and attributes as spatial features, StyleSwap achieves state-of-the-art results in identity similarity and image quality. Furthermore, we introduce a novel "Swapping-Guided ID Inversion" strategy to refine identity transfer without sacrificing the model's generalization capabilities.

Introduction

Face swapping is a classic challenge in computer vision. The core difficulty lies in information balancing: over-emphasizing the source identity often leads to the loss of target expressions or lighting, while over-emphasizing the target results in poor identity fidelity. Existing methods frequently rely on complex, hand-crafted architectures and intricate loss functions that struggle with high-resolution outputs, temporal coherence, or "ghosting" artifacts. StyleSwap addresses these issues by adapting a pre-trained StyleGAN2 architecture as a powerful generative prior.

Methodology

The StyleSwap architecture modifies StyleGAN2 with three key components to facilitate robust face swapping.

Overview of the StyleSwap architecture, featuring identity and attribute encoding branches and a swapping-driven mask branch.

1. Infusing Attribute Information

Unlike standard StyleGAN2, which uses constant inputs, StyleSwap employs an attribute encoder ($E_{att}$) to extract spatial feature maps from the target image ($I_t$). These maps are concatenated to the generator blocks, effectively preserving structural information like pose, hair, and background.

2. Injecting Identity Features

Source identity ($I_s$) is extracted using a pretrained ArcFace model and mapped into the StyleGAN $W$ space. This allows modulated convolutions to blend the source identity with target attributes naturally.

3. Swapping-Driven Mask Branch

A "ToMask" branch, inspired by StyleGAN’s "ToRGB" layers, predicts a soft mask ($M_g$). This mask guides the model in distinguishing between the face region to be swapped and the original target elements (e.g., hair, background) that should remain unchanged.

4. Swapping-Guided ID Inversion

To further enhance identity similarity, we introduce Swapping-Guided ID Inversion. Unlike standard GAN inversion, which can lead to mode collapse, this strategy iteratively performs face swapping with randomly sampled target faces during latent space optimization. This forces the model to optimize for the person's identity rather than a specific pixel reconstruction.

Experiments and Results

StyleSwap was trained on VGGFace and VoxCeleb2 (enhanced to 512x512 using GPEN) and evaluated on FaceForensics++ and CelebA-HQ.

Qualitative results of StyleSwap showing successful identity transfer across various poses and lighting conditions.

Quantitative Performance

StyleSwap outperforms state-of-the-art (SOTA) methods like SimSwap and FaceShifter:

  • Identity Retrieval: Achieved 97.05% (97.87% with $W^+$ optimization), surpassing SimSwap's 93.07%.
  • Image Quality: Recorded an FID score of 2.72, indicating superior visual fidelity.

Qualitative Analysis

As shown in the results, StyleSwap handles extreme lighting and complex poses where other models often produce artifacts or incorrect skin tones. User studies confirmed that StyleSwap is preferred for identity similarity and overall naturalness.

Conclusion

StyleSwap demonstrates that StyleGAN2 can be effectively repurposed for face swapping by treating identity as style and attributes as spatial features. While the $W^+$ optimization is computationally intensive, it provides a path for high-precision swapping. Future work includes accelerating the inversion process and addressing the ethical implications of high-quality face forgery by providing data for detection research.

Summary updated

BibTeX
@inproceedings{xu2022styleswap,
  author = {Zhiliang Xu and Hang Zhou and Zhibin Hong and Ziwei Liu and Jiaming Liu and Zhizhi Guo and Junyu Han and Jingtuo Liu and Errui Ding and Jingdong Wang},
  title = {{StyleSwap: Style-Based Generator Empowers Robust Face Swapping}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19781-9\_38},
}
Figure