ReHiFace-S,硅基智能开源的实时换脸项目,只需一张照片,一键即可将视频中的脸部替换为目标人物形象
Go to file
GuijiIntelligence 384e720d1e update file
2024-08-20 17:33:09 +08:00
.idea Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
assets Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
data Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
face_detect Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
face_feature Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
face_lib/face_swap Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
face_restore Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
model_lib Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
options Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
.gitignore update file 2024-08-20 17:33:09 +08:00
app.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
color_transfer.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
HifiFaceAPI_parallel_base.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
HifiFaceAPI_parallel_trt_roi_realtime_api.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
HifiFaceAPI_parallel_trt_roi_realtime_sr_api.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
inference_cam.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
inference.py Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
LICENSE Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00
README.md first commit 2024-08-20 17:04:05 +08:00
requirements.txt Real Time High-Fidelity Faceswap 2024-08-20 17:06:10 +08:00

ReHiFace-S 🤖🤖🤖

🚀 Introduction

ReHiFace-S, short for “Real Time High-Fidelity Faceswap”, is a real-time high-fidelity faceswap algorithm created by Silicon-based Intelligence. By open-sourcing the capabilities of digital human generation, developers can easily generate large-scale digital humans who they want, enabling real-time faceswap capability.

💪 Project features

  • Real-time on NVIDIA GTX 1080Ti
  • Zero-shot inference
  • High Fidelity faceswap
  • Support ONNX and live camera mode
  • Support super resulution and color transfer
  • Better Xseg model for face segment

🔥 Examples

We show some faceswap examples.

showcase

showcase

🔧 Getting Started

Clone the code and prepare the environment

conda create --name faceswap python=3.9
conda activate faceswap
pip install -r requirements.txt

😊 Pretrained models

Download all pretrained weights from Google Drive or Baidu Yun. We have packed all weights in one directory 😊. Download and place them in ./pretrain_models folder ensuring the directory structure is as follows:

pretrain_models
├── 9O_865k.onnx
├── CurricularFace.tjm
├── gfpganv14_fp32_bs1_scale.onnx
├── pfpld_robust_sim_bs1_8003.onnx
├── scrfd_500m_bnkps_shape640x640.onnx
├── xseg_230611_16_17.onnx

💻 How to Test

CUDA_VISIBLE_DEICES='0' python inference.py

Or, you can change the input by specifying the --src_img_path and --video_path arguments:

CUDA_VISIBLE_DEICES='0' python inference.py --src_img_path --video_path

Live Cam faceswap

You should at least run by NVIDIA GTX 1080Ti.

Notice: The time taken to render to a video and warm up the models are not included.

Not support Super Resolution.

CUDA_VISIBLE_DEICES='0' python inference_cam.py

Notice: Support change source face during live with 'data/image_feature_dict.pkl' !

showcase

showcase

🤗 Gradio interface

We also provide a Gradio interface for a better experience, just run by:

python app.py

Acknowledgments

  • Thanks to Hififace for base faceswap framework.
  • Thanks to CurricularFace for pretrained face feature model.
  • Thanks to Xseg for base face segment framework.
  • Thanks to GFPGAN for face super resolution.
  • Thanks to LivePortrait and duix.ai for README template.

🌟 Citation

If you find ReHiFace-S useful for your research, welcome to 🌟 this repo.