Python end-to-end pipeline to swap faces in videos and images.
The aim of this code is to implement an end-to-end pipeline to swap faces in a video just like Snapchat’s face swap filter or this face swap website. The following figure shows an illustration of the face swap where we swap Ron Weasley's face with Hermione Granger's face.
1- If you want to see triangulation and landmark detection on an arbitrary image run this:
python Wrapper.py --triangulation [path to the image]
Download the PRN trained model at BaiduDrive or GoogleDrive, and put it into codes/Data/net-data
Link: https://drive.google.com/file/d/1UoE-XuW1SDLUjZmJPkIZ1MLxvQFgmTFH/view
2- To swap faces of two arbitrary images run this:
python Wrapper.py --image_swap true --src_image [path to source image] --dst_image [path to destination image] --method [metod key]
Note: Method key should be choosen between tri, tps, or prnet.
"tri" stands for Delaunay Triangulation.
"tps" stands for Thin Plate Splines.
"prnet" stands for PR Net.
3- Two swap a face in a video with an target image run this:
python Wrapper.py --video [path to the .mp4 video] --image [path to destination image] --method [metod key] --name [output video name]
Note: You can set frame per second by setting --fps [your desire frame per second]
4- Two swap two faces in a video run this:
python Wrapper.py --video [path to the .mp4 video] --tf true --method [metod key] --name [output video name]
Note: You can set frame per second by setting --fps [your desire frame per second]
Note1: For the full project description click here.
Note2: For the full documentation click here.