Skip to content

justld/dofaker

Repository files navigation

English|简体中文

colab

DoFaker: A very simple face swapping tool

Insightface based face swapping tool to replace faces in videos or images. Windows and linux support CPU and GPU. Onnxruntime inference without pytorch.

Update

  • 2023/9/16 update pose transfer model
  • 2023/9/14 update face enhance(GFPGAN) and image super resolution(BSRGAN)

Tutorial

Qiuck Start

install dofaker

git clone https://github.com/justld/dofaker.git
cd dofaker
conda create -n dofaker
conda activate dofaker
pip install onnxruntime # onnxruntime-gpu
pip install -e .

open web ui(The model weights will be downloaded automatically):

dofaker

command line(linux):

bash test.sh

Install from source code

一、Installation

You should install onnxruntime or onnxruntime-gpu manually.

conda install

create virtual environment:

git clone https://github.com/justld/dofaker.git
cd dofaker
conda create -n dofaker
conda activate dofaker
pip install -r requirements.txt
pip install onnxruntime # onnxruntime-gpu
pip install -e .

pip install

git clone https://github.com/justld/dofaker.git
cd dofaker
pip install -r requirements.txt
pip install onnxruntime # onnxruntime-gpu
pip install -e .

二、Download Weight

All weights can be downloaded from release. These weight come from links refer to the botton links.

Unzip the zip file, the dir looks like follow:

|-dofaker
|-docs
|-weights
----|-models
--------|-buffalo_l
----------|-1k3d68.onnx
----------|-2d106det.onnx
----------|-...
--------|-buffalo_l.zip
--------|-inswapper_128.onnx
--------|-GFPGANv1.3.onnx
--------|-bsrgan_4.onnx
|-run_faceswapper.py
|-web_ui.py

三、Usage

You can use dofaker in web_ui or command line.

web ui

web gui only support one face swap once, if you want to swap multiple faces, please refer to command usage.

python web_ui.py

command

You can swap multiple faces in command.

python run_faceswapper.py --source "image or video path to be swapped" --dst_face_paths "dst_face1_path" "dst_face2_path" ... --src_face_paths "src_face1_path" "src_face2_path" ...

The command follow will replace dst_face1 and dst_face2 detected in input_video.mp4 with src_face1 and src_face2:

python run_faceswapper.py --source input_video.mp4 --dst_face_paths dst_face1.jpg dst_face2.jpg --src_face_paths src_face1.jpg src_face2.jpg
args description
source The image or video to be swapped
dst_face_paths The images includding faces in source to be swapped. If None, replace all faces in source media.
src_face_paths The images includding faces in source to be swapped

Attention

Do not apply this software to scenarios that violate morality, law, or infringement. The consequences caused by using this software shall be borne by the user themselves.

Sponsor

Thank you for support

Thanks