Skip to content

RudyChin/face_swap

 
 

Repository files navigation

Acknowledgement

This work is done when the author was interning at AILabs.tw

Dockerized Image

Please refer to rudychin/face_swap_docker for more detail

Fast Face Swap

Inherit from YuvalNirkin/face_swap, this is a boosted version.

Overview

The pipeline of the framework is modified into a more efficient one. Specifically, we have the following contributions:

  • Merge expression regression into ResNet-101, which was used to regress shape and texture as illustrated in CNN3DMM. Hence, we completely throw away the computation overhead of expression approximation in the original pipeline. We fine-tuned the network with images from LFW and MegaFace.

  • Replace dlib face detection in two ways:

  1. Use YOLO instead (please refer to the yolo branch)
  2. Count on KCF tracking with dlib face detection (please refer to the kcf branch)
  • We make it a shared library and develop a python wrapper for the ease-of-use.

Compare the original performance and the accelerated version (SmallerNet + Tracking + Downsampling):

Original Performance

Acclerated Performance Breakdown

Compare KCF (slow detect + track, top row) to YOLO (fast detect, bottom row)

Dependencies

Library Minimum Version Notes
Boost 1.47
OpenCV 3.0
face_segmentation 0.9
Caffe 1.0 ☕️
Eigen 3.0.0
GLEW 2.0.0
Qt 5.4.0
HDF5 1.8.18
KCFcpp master

Installation

mkdir build
cd build
cmake -DCMAKE_CXX_STANDARD=14 ..
make
make install

Usage

Please modify the path within py_face_swap/pytest.py before you run it.

To swap an image, please modify from py_face_swap/pytest.py. To swap a video, use tools/swapVideo.py.

Known Issues

  1. When face is moving to or from the screen, bounding box does not grow or shrink accordingly properly.
  2. We count on failure pose estimation to detect the failure of tracking passively. One possible solution is to use discriminative tracker, e.g. GOTURN

Related projects

About

End-to-end, automatic face swapping pipeline

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 94.5%
  • CMake 3.4%
  • Python 2.0%
  • C 0.1%