Introduction
Face swapping involves transplanting a source identity onto a target face while maintaining the target's expressions, poses, and lighting conditions. Despite significant progress, current state-of-the-art methods often struggle with a fundamental trade-off between global consistency and local detail. Traditional approaches frequently suffer from "identity leakage"—where source attributes like hair or background bleed into the target—or a loss of fine-grained facial features, such as the specific contour of an eye.
RAFSwap (Region-Aware Face Swapping) addresses these challenges through a novel framework that combines a Transformer-based local region branch with a global feature-adaptive branch. By leveraging an unsupervised soft mask predictor integrated with StyleGAN2, RAFSwap achieves superior identity consistency and high-resolution results without the common artifacts associated with rigid blending masks.
Methodology
The RAFSwap architecture is built upon the pixel2style2pixel (pSp) framework, utilizing StyleGAN2 as the primary decoder. The system's innovation is centered on its dual-branch processing strategy.
Local Facial Region-Aware (FRA) Branch
The FRA branch serves as the core mechanism for capturing identity-specific details. It utilizes a Region-Aware Identity Tokenizer (RAT) to decompose the source face into semantic tokens representing specific regions (e.g., eyes, nose, mouth). These tokens are processed by a Transformer to model spatial interactions across multiple scales. Finally, a Region-Aware Identity Projector (RAP) adaptively maps these tokens onto the target face's spatial features. This approach allows the model to handle misalignments between source and target faces effectively, as the Transformer learns relationships between features regardless of their exact pixel coordinates.
Global Source Feature-Adaptive (SFA) Branch
Complementing the FRA branch, the SFA branch captures broader identity cues, such as skin texture and the relative proportions of facial components. This ensures that the overall "vibe" of the source identity is preserved while the FRA branch handles the intricate details.
Face Mask Predictor (FMP)
To ensure seamless integration, the authors developed the Face Mask Predictor (FMP). Unlike traditional methods that use fixed "hard" masks, the FMP is an unsupervised module that extracts semantic information from StyleGAN2’s internal feature maps. It predicts a "soft" mask that facilitates smooth blending between the generated face and the original target's hair and background, effectively eliminating visible seams.
Experimental Evaluation
The researchers evaluated RAFSwap using standard benchmarks, including CelebA-HQ for training and FaceForensics++ for testing identity retrieval and attribute preservation.
Quantitative Performance
On the FaceForensics++ dataset, RAFSwap achieved a state-of-the-art identity retrieval score of 96.70%. This represents a significant improvement over previous leaders like MegaFS, which scored 90.83%. This metric underscores the model's ability to maintain the source identity even under varying target conditions.
Qualitative Results and Versatility
Qualitative analysis demonstrates that RAFSwap excels in challenging scenarios, such as source faces with complex hairstyles (e.g., bangs or white hair) where other models like SimSwap or FaceShifter often produce identity confusion or blurriness. Furthermore, the FRA branch's robustness allows it to be applied to makeup transfer tasks. In these applications, RAFSwap outperformed specialized models like PSGAN in both visual quality and computational efficiency, operating over 10x faster on a GPU.
Conclusion and Future Work
RAFSwap represents a significant advancement in high-resolution face swapping by prioritizing region-aware feature modeling and seamless blending. While the model is highly effective, it remains limited by the diversity of its training data, occasionally struggling with extreme side profiles or unusual perspectives. Future research will focus on incorporating 3D facial priors and more diverse datasets to improve the model's ability to generalize to extreme angles, further refining the realism of digital identity transfer.
Summary updated