- This code was primarily written in the summer of 2023.
- The code was not tested before committing.
- Contributions and pull requests are welcome.
- Introduction
- Requirements and Installation
- Training
- Inference
- Results
- Evaluation and Performance Metrics
- Citation
- License
- Code Author
Official Implementation for LatentSwap:An Efficient Latent Code Mapping Framework for Face Swapping.
docker build . -t latentswap:latest
docker run -it --ipc host --gpus "device=0" -v /PATH_TO_SAVE:/DATA --name latentswap latentswap:latest
Download checkpoint from official checkpoint and copy it to '/workspace/' in docker container.
docker cp ffhq.pkl latentswap:/workspace/
Download checkpoint with this link and copy it to '/workspace' in docker container.
docker cp epoch=5-step=109999.ckpt latentswap:/workspace/
Follow the guideline in Prepare prerequisite models at /workspace/model/Deep3DFaceRecon_pytorch/
folder.
docker cp latentswap:/workspace/model/Deep3DFaceRecon_pytorch/BMF/
docker cp epoch_20.pth latentswap:/workspace/model/Deep3DFaceRecon_pytorch/checkpoints
python latentswap_trainer.py --help
Download the pre-trained model from this link.
docker cp epoch=39-step=200000.ckpt latentswap:/workspace/
python pti_inversion_inference.py --model_checkpoint_path 'epoch=39-step=200000.ckpt' --target_image_path TARGET_PATH --source_image_path SOURCE_PATH
Ensure all images follow the preprocessing steps of FFHQ.
Model | ID ↑ | Expression ↓ | Pose ↓ | Params ↓ |
---|---|---|---|---|
DeepFakes | 88.39 | 0.1705 | 13.38 | Unknown |
FaceShifter | 90.68 | 0.1223 | 7.65 | 250M |
SimSwap | 89.73 | 0.0879 | 5.82 | 120M |
HifiFace | 98.48 | NA | 7.89 | 244M |
MegaFS | 90.83 | 0.1348 | 7.92 | 338M |
RAFSwap | 96.70 | 0.1312 | 7.59 | Unknown |
InfoSwap | 99.67 | 0.1427 | 9.07 | 251M |
Ours | 93.36 | 0.0673 | 4.06 | 87M |
Note: Our model achieves comparable performances to other face swapping models for ID and better performance for all other metrics.
Choi, Changho, et al. "LatentSwap: An Efficient Latent Code Mapping Framework for Face Swapping." arXiv preprint arXiv:2402.18351 (2024).
Changho Choi @ Korea Univ. (changho9808@gmail.com)