Given a video clip, a user profile and an actor(actress) profile in the video, Swap the actor's face with the user's face. In a word, just replace the face of an actor with the input image for fun.
Install the prerequisites before using this module
- Install Cmake
- Install GCC(version>=4.8)
- Install ffmpeg
-
pip3.5 install -r requirements.txt
Note: You will also need the facial landmark detector. The trained model can be downloaded from the source. Then, you can place it in the same directory where main.py
is placed.
python main.py $video_address $user_face_address $selected_actor_address $temp_address $output_video
E.g. python main.py ./data/videos/video.mp4 ./data/images/user.jpeg ./data/images/actor.jpeg ./output/ ./output/output.mp4
-
To accelerate the program, multiprocessing is used, but it will comsume all your memory. If you are not interested in the computation time, you can comment this part out in
faceswap.py
and use sequential procedures.cores = multiprocessing.cpu_count() pool = multiprocessing.Pool(processes=cores) pool.map(faceswapper, actors) pool.close() pool.join()
Thanks to face_recognition by Adam Geitgey and faceswap by Matthew Earl.