Fast Face-Swap Using Convolutional Neural Networks

Iryna Korshunova, Wenzhe Shi, Joni Dambre, Lucas Theis

Abstract

We consider the problem of face swapping in images, where an input identity is transformed into a target identity while preserving pose, facial expression and lighting. To perform this mapping, we use convolutional neural networks trained to capture the appearance of the target identity from an unstructured collection of his/her photographs. This approach is enabled by framing the face swapping problem in terms of style transfer, where the goal is to render an image in the style of another one. Building on recent advances in this area, we devise a new loss function that enables the network to produce highly photorealistic results. By combining neural networks with simple pre- and post-processing steps, we aim at making face swap work in real-time with no input from the user.

Introduction

Face-swapping has evolved from a tedious manual editing task to a viral digital phenomenon. While early methods relied on complex 3D modeling or massive image databases, this research introduces a more elegant approach: treating identity as "style."

Traditional computer vision methods, such as 3D morphable models, are often slow and require manual guidance. Conversely, early Neural Style Transfer (NST) techniques excel at texture but often fail at photorealism, distorting spatial layouts and creating "melted" results. This work addresses the challenge of replacing Identity A with Identity B while maintaining the pose, expression, gaze, and lighting of Identity A in real-time.

Methodology

The proposed system utilizes a feed-forward transformation network instead of the slow optimization processes typical of original NST.

Multi-Scale Architecture

The network employs a multi-scale architecture that processes images at different resolutions (e.g., 128x128 and 256x256). This allows the model to capture both fine-grained details and global facial structures simultaneously.

Multi-Image Style Loss

Unlike standard style transfer which uses a single reference, this approach introduces a multi-image style loss. During training, the network compares the generated face against a collection of approximately 60 images of the target person. By selecting the "best matching" patches from this collection, the network learns the manifold of the target's identity rather than mimicking a single specific photograph.

Lighting Preservation

To achieve photorealism, the swapped face must respect the original scene's lighting. Standard VGG networks used for content loss are often lighting-invariant. To solve this, a separate Siamese lighting network was trained on the Extended Yale Face Database B. This network provides a "lighting loss" that forces the output to preserve the source's shadows and highlights.

Figure 1: Face swap results showing (a) source image, (b) intermediate result, and (c) final photorealistic swap to the target identity (Nicolas Cage).

Implementation and Preprocessing

The pipeline includes essential pre- and post-processing steps. Faces are first detected and aligned using facial landmarks to ensure consistent input to the transformation network. This preprocessing ensures the network can focus on identity transfer rather than spatial orientation.

Figure 6: Facial landmark detection used for alignment during the preprocessing stage.

Results

The system achieves significant speed and quality benchmarks:

  • Performance: A feed-forward pass takes approximately 40ms for a 256x256 image on a GTX Titan X. The entire pipeline, including alignment and stitching, is fast enough for near real-time applications.
  • Expression Preservation: The results demonstrate significant changes to facial features (nose, eyes, wrinkles) while maintaining the exact gaze direction and emotional expression of the source.

Limitations

Despite its success, the model has several limitations:

  1. Head Shape: The network primarily modifies internal features and does not significantly alter the overall head shape or jawline.
  2. Occlusions: Objects in front of the face, such as glasses or hands, are often incorrectly "painted over" with skin textures.
  3. Profile Views: Quality decreases for profile shots due to the frontal bias in training datasets like CelebA.
  4. Sharpness: Some outputs appear slightly oversmoothed; future work could incorporate Adversarial Loss (GAN) to recover sharper textures.

Summary updated

BibTeX
@inproceedings{korshunova2017fast,
  author = {Iryna Korshunova and Wenzhe Shi and Joni Dambre and Lucas Theis},
  title = {{Fast Face-Swap Using Convolutional Neural Networks}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2017},
  url = {https://openreview.net/forum?id=B1ZKReMdbB},
}
Figure