Abstract
FaceInpainter is a novel two-stage framework that redefines face swapping as an identity-guided inpainting task. This approach enables high-fidelity face adaptation across vastly different domains, ranging from photorealistic images to 3D cartoons, caricatures, and oil paintings. By disentangling facial attributes using 3D priors and employing a joint refinement network, FaceInpainter achieves superior identity preservation and attribute consistency compared to existing state-of-the-art methods.
Introduction
Traditional face-swapping techniques, such as DeepFakes or FaceShifter, often falter when the source and target images originate from heterogeneous domains. Swapping a real human face onto a stylized 3D character or a pencil sketch introduces significant challenges, including domain mismatch, boundary artifacts, and attribute distortion. Most existing methods rely heavily on pixel-level matching, which fails when styles are fundamentally misaligned.
FaceInpainter addresses these issues by shifting the paradigm from simple "swapping" to "inpainting" a new identity into a pre-existing context. This perspective allows the model to prioritize the integration of the face with its surrounding environment, such as hair, neck, and background, resulting in cleaner transitions and more natural results.
Methodology
The FaceInpainter pipeline consists of two primary stages designed to bridge the gap between disparate domains.
Stage 1: Styled Face Inpainting Network (SFI-Net)
The first stage focuses on fitting the source identity into the target's pose and expression. The model extracts 3D Morphable Model (3DMM) parameters from the target to capture precise geometry, while a pretrained face recognition model extracts a high-level identity latent code from the source. These components are fused within a StyleGAN-based generator to produce a coarse swapped face that aligns with the target's background and lighting.
Stage 2: Joint Refinement Network (JR-Net)
To address issues like occlusions and blurry boundaries, the Joint Refinement Network (JR-Net) utilizes Adaptive Instance Normalization (AdaIN) to sharpen identity and texture details. A key innovation here is the use of Contextual Loss, which allows for slight spatial deformations. This is crucial when the source and target have different face shapes, such as a caricature versus a standard photo. Additionally, the Dictionary Feature Transfer (DFT) module uses a library of high-quality facial components to inject fine-grained details into the final output.
Experimental Evaluation
The model was trained on high-quality photo datasets like CelebA-HQ and FFHQ and evaluated across both photorealistic and heterogeneous benchmarks.
- Quantitative Performance: On the FaceForensics++ benchmark, FaceInpainter achieved an ID retrieval score of 97.63%, outperforming SimSwap (92.83%). It also recorded the highest image sharpness score (SMD2 of 11.708), indicating superior blending at fusion boundaries.
- Cross-Domain Success: In tests on the IIIT-CFW (cartoon) and CUHK Face Sketch datasets, FaceInpainter significantly outperformed traditional methods in both identity preservation and attribute fidelity.
- User Preference: A large-scale human study involving 10,000 decisions ranked FaceInpainter highest in identity perception and overall realism.
Conclusion and Future Work
FaceInpainter demonstrates that treating face swapping as an inpainting task, supported by 3D priors and contextual refinement, effectively solves the challenges of cross-domain face adaptation. While the model handles many occlusions gracefully, extreme cases involving intricate jewelry or dense veils remain a challenge. Future research will focus on improving parsing robustness and extending the framework to maintain temporal consistency in high-fidelity video face swapping.
Summary updated