MobileFaceSwap: A Lightweight Framework for Video Face Swapping

Zhiliang Xu, Zhibin Hong, Changxing Ding, Zhen Zhu, Junyu Han, Jingtuo Liu, Errui Ding

Introduction

Face swapping—the process of transferring a source person's identity onto a target video while preserving expressions and backgrounds—has traditionally been a computationally intensive task. Leading models like FaceShifter and SimSwap require hundreds of millions of parameters and tens of billions of floating-point operations (FLOPs) per frame. This heavy computational load makes real-time execution on mobile devices nearly impossible. Furthermore, standard compression techniques often fail in this domain, as shrinking the network typically leads to "identity leakage" or significant visual artifacts.

MobileFaceSwap addresses these challenges by introducing a hyper-efficient framework designed for high-quality, real-time video face swapping on edge devices. By utilizing a dynamic neural network that adapts its parameters based on the source identity, the authors achieved a 100x reduction in computational costs compared to state-of-the-art models while maintaining comparable visual fidelity.

Methods: Identity-aware Dynamic Networks

The core innovation of MobileFaceSwap is the Identity-aware Dynamic Network (IDN). Unlike static models with fixed weights, the IDN dynamically adjusts its filters based on the specific source face being processed. This allows a small network to specialize itself for a specific identity during inference, maximizing efficiency.

Overview of the MobileFaceSwap framework, including the Identity Injection Module (IIM) and the knowledge distillation pipeline with loss reweighting.

Key Technical Components

  • Identity Injection Module (IIM): This module serves as the heart of the system. It employs two dynamic techniques: Weights Prediction for depthwise convolutions and Weights Modulation for pointwise convolutions. The source face's identity embedding (extracted via a pre-trained ArcFace model) acts as a set of instructions to "re-wire" the IDN's filters on the fly.
  • Knowledge Distillation (KD) with Loss Reweighting: To train the lightweight "student" model, the authors used much larger "teacher" models (SimSwap and FaceShifter) as references. Recognizing that teachers can sometimes produce artifacts, they designed a Loss Reweighting Module to evaluate the quality of the teacher's output. If the teacher produces a poor swap, the student's loss is down-weighted to prevent it from learning errors.
  • Weakly Semantic Fusion Module: To ensure temporal stability and seamless blending, this lightweight module predicts a fusion mask that integrates the swapped face into the original target frame, preserving hair and background details.

Datasets and Training

The model was trained on a refined subset of VGGFace2, consisting of 550,000 images selected for high-quality facial features. Quantitative benchmarks were conducted on the FaceForensics++ dataset, while qualitative testing utilized CelebA-HQ and high-resolution web images to demonstrate real-world performance.

Key Results and Performance

The efficiency gains of MobileFaceSwap are significant. The IDN utilizes only 0.50M parameters and 0.33G FLOPs, representing a 146x reduction in computation compared to SimSwap (107M parameters and 55.7G FLOPs). On a MediaTek Dimensity 1100 mobile chip, the model achieves 26 FPS without requiring hardware-specific quantization.

Qualitative comparison of MobileFaceSwap against state-of-the-art models SimSwap and FaceShifter.

In terms of visual fidelity, the model achieved an identity retrieval accuracy of 95.98%, which is comparable to its much larger teacher models. Qualitative results indicate that MobileFaceSwap often produces fewer artifacts around the eyes and forehead than SimSwap, likely due to the quality-aware distillation process.

Conclusion

MobileFaceSwap demonstrates that dynamic networks can bridge the gap between high-end facial manipulation and mobile hardware constraints. By treating identity information as a modulator for weights rather than just a feature map, the framework achieves deep identity integration with minimal parameters. While the authors acknowledge the potential for misuse in creating malicious forgeries, they hope this efficient framework will also aid in the development of more robust deepfake detection tools.

Summary updated

Abstract

Advanced face swapping methods have achieved appealing results. However, most of these methods have many parameters and computations, which makes it challenging to apply them in real-time applications or deploy them on edge devices like mobile phones. In this work, we propose a lightweight Identity-aware Dynamic Network (IDN) for subject-agnostic face swapping by dynamically adjusting the model parameters according to the identity information. In particular, we design an efficient Identity Injection Module (IIM) by introducing two dynamic neural network techniques, including the weights prediction and weights modulation. Once the IDN is updated, it can be applied to swap faces given any target image or video. The presented IDN contains only 0.50M parameters and needs 0.33G FLOPs per frame, making it capable for real-time video face swapping on mobile phones. In addition, we introduce a knowledge distillation-based method for stable training, and a loss reweighting module is employed to obtain better synthesized results. Finally, our method achieves comparable results with the teacher models and other state-of-the-art methods.
BibTeX
@inproceedings{xu2022mobilefaceswap,
  author = {Zhiliang Xu and Zhibin Hong and Changxing Ding and Zhen Zhu and Junyu Han and Jingtuo Liu and Errui Ding},
  title = {{MobileFaceSwap: A Lightweight Framework for Video Face Swapping}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i3.20203},
}
Figure