Face swap using Python + OpenGL
This implementation finds facial landmarks on both the source and destination images, and generates a texture to be used on a 3D model of the face. This Model is then positioned over the destination image using the landmarks.
Source | Destination | Texture | 3D face | Result |
---|---|---|---|---|
Clone the repo
git clone https://github.com/ibonn/faceswap_gl.git
Install required modules
cd faceswap_gl/
pip install -r requirements.txt
Basic usage
python swap.py -s <SRC_PATH> -d <DST_PATH> -o <OUT_PATH>
More options:
- -s/--src: Path to the source image
- -d/--dst: Path to the destination image/video
- -o/--output: Output path
- -t/--texture: Size of the texture. The lower the value the faster the program starts (but the source face resolution is lower). Defaults to 256px
- -b/--border: Padding size. Not implemented yet
- -m/--mask: Output a video with the mask
Example:
python swap.py -s tomhanks.jpg -d dicaprio.mp4 -o out.mp4 -t 1024