Inspired by the amazing work done daily by Eameo, I put together this simple script that
switch faces between two input images. You can run the step-by-step ipynb in Google Colab
or run python faceswap.py
directly.
This script supports Python 2.7 and 3.6.
$ git clone https://github.com/nicolasmetallo/eameo-faceswap-generator.git
Run the following to install Dlib in Google Colaboratory.
!apt update
!apt install -y cmake
!pip install dlib
Click here for MacOS/Ubuntu instructions or Windows.
Run the following to install required modules
$ pip install -r requirements.txt
This script requires the user to input three file paths which can be local paths or URLs:
- from_image = 'Path to first image where you will extract the face.'
- to_image = 'Path to second image where you will swap the existing face'
- output_filename = 'Path to output image.'
Now let's take two input images and set result.jpg
as the output file.
$ python faceswap.py image1.jpg image2.jpg result.jpg