NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Face Swapping as A Simple Arithmetic Operation

Truong Vu, Kien Do, Khang Nguyen, Khoat Than

Abstract

Recent advancements in high-fidelity face swapping have often relied on complex fusion modules or heavy post-processing to manage information entanglement. We present Arithmetic Face Swapping (AFS), a novel approach that performs face swapping through simple vector arithmetic within StyleGAN’s $W+$ latent space. By explicitly disentangling a face into additive "identity" and "style" components, swapping becomes a fundamental mathematical operation: adding the identity vector of a source to the style vector of a target. Our method achieves state-of-the-art performance in identity preservation and visual realism while maintaining mathematical stability for sequential operations.

Introduction

The goal of face swapping is to transplant a source identity onto a target's attributes—such as pose, expression, and lighting—while preserving the target's background. Despite the realism offered by Generative Adversarial Networks (GANs), many existing methods suffer from information entanglement, where the resulting image retains unwanted source attributes (e.g., hair) or loses target-specific expressions. To address this, we propose making the latent space itself more intuitive, treating disentanglement as a linear separation rather than a complex feature-fusion task.

Methodology

Arithmetic Face Swapping (AFS) operates on the $W+$ latent space of a pre-trained StyleGAN2. The core hypothesis is that any latent code $w$ can be decomposed into $w = w_{id} + w_{sty}$, where $w_{id}$ resides in an identity subspace and $w_{sty}$ in a style subspace.

Overview of the Arithmetic Face Swapping (AFS) architecture, demonstrating the decomposition of latent codes into identity and style components for swapping.

The Style Extractor ($h$)

To achieve this decomposition, we train a neural network $h$ to extract the style component from a latent code ($w_{sty} = h(w)$). The identity component is then defined as the remainder: $w_{id} = w - h(w)$. Because $W+$ consists of 18 distinct 512-dimensional vectors, $h$ is implemented as 18 separate sub-networks utilizing highway layers to selectively process information. The final swapped latent code $\tilde{w}$ is calculated as: $$\tilde{w} = w_{id}^{source} + w_{sty}^{target}$$

Training Objectives

The network $h$ is trained using a combination of loss functions:

  • ID Loss: Utilizing ArcFace to ensure the output matches the source identity.
  • Perceptual Loss: Ensuring the output retains the target's coarse attributes and textures.
  • Consistency Loss: A critical constraint ensuring $h(\tilde{w}) = h(w^{target})$, which facilitates stable "chains" of swaps.

Key Insights and Stability

Unlike methods that use attention mechanisms or concatenation, AFS treats disentanglement as a linear separation, making the process highly interpretable. A significant advantage of our approach is its mathematical stability. Due to the Consistency Loss, AFS supports sequential operations—swapping Identity A onto Target B, then swapping that result onto Target C—without the "melting" artifacts common in other state-of-the-art (SOTA) methods. Furthermore, this arithmetic nature allows for identity interpolation, where users can blend multiple source identities onto a single target style.

Experimental Results

We evaluated AFS using the CelebA-HQ dataset, comparing it against SOTA baselines including FSGAN, FaceShifter, and MegaFS.

Qualitative comparison of AFS against state-of-the-art methods and an ablation study demonstrating the importance of the consistency loss for visual fidelity.

Quantitative Performance

  • Identity Preservation: AFS achieved the highest ID similarity score (0.49) among tested models.
  • Visual Realism: Our method produced a significantly lower Fréchet Inception Distance (FID) of 4.56, compared to 12.16 for FaceShifter and 67.00 for FSGAN.
  • Robustness: The model handles occlusions and extreme pose differences gracefully without requiring explicit face masking, maintaining target expressions more effectively than most competitors.

Conclusion and Future Work

AFS demonstrates that high-fidelity face swapping can be achieved through simple latent space arithmetic. While the method is robust, it remains sensitive to extreme texture differences between source and target and is inherently limited by the inversion quality of the initial encoder (e4e). Future research will focus on refining the style extractor architecture and exploring more complex training objectives to further isolate identity from fine-grained style attributes.

Summary updated

BibTeX
@misc{vu2022face,
  author = {Truong Vu and Kien Do and Khang Nguyen and Khoat Than},
  title = {{Face Swapping as A Simple Arithmetic Operation}},
  year = {2022},
  eprint = {2211.10812},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.10812},
}
Figure