FaceSwap program written in Python, using Dlib and OpenCV libraries. While Dlib is used to capture the landmarks over a face, OpenCV is used to manipulate the images data. It takes two files as input, where each one must contain only one face, the source face and the destination face, respectively.
- Python 3.0+
- OpenCV3
- Dlib
You can install Python 3.0+ by downloading it from here.
To install OpenCV, follow these steps here.
Next, to install Dlib, you may follow these steps here.
Once you got all depencies installed and both files downloaded, go to directory containing those files and run the following command:
$ python faceSwap.py <image1> <image2>
Where image1 is the name of the file containing the source face, and image2 is the name of the file containing the destination face.
At first, you'll have to build the docker image by running the script docker-build.sh
:
$ ./docker-build.sh
Note: It may take a long time to build the image at the first time, be patient!
Once the image is built, you may run it with the help of the script docker-run.sh
:
$ ./docker-run.sh
The application will be running at the port 5000.
Once the application is up and running, you may send requests to faceswap images:
$ curl --location --request GET 'http://127.0.0.1:5000?source=<img1>&target=<img2>' > output.jpeg
Where img1 is the URL of the source image, img2 is the URL of the target image and output is the name of the resulting file