This a quick update on how to use Scene Selector to prepare and merge movie frames for a face swapped movie. You still need code from https://github.com/deepfakes/faceswap.
In short, face-swapping a movie includes 3 steps:
- Extract faces of two different faces. You will need many of them for different expressions and positions in order to get a good result.
- Train the model to learn how to transform from face A to face B from the data of step 1.
- Convert the face on each movie frame and merge back to a movie.
Every step involves the heavy usage of GPU, though it can run with CPU. It is about 1/10 of speed comparing to GPU. Especially for step 2, if you started from a pretrained model, it takes about 4-6 hours to generate a new good model ( on AMD RX580 eGPU). It takes significant time running it on CPU.
Here is the step by step instruction if you don’ t have python virtual environment ready.
Go to https://brew.sh and install Homebrew with the terminal command on the page.
- Create your isolated environment with command. You can use your preferred location.
brew install pyenv-virtualenv pyenv install 3.6.6 pyenv virtualenv 3.6.6 faceswap-env
Add following lines to enviroment(pre-10.15: ~/.bash_profile, 10.15 if you use zsh: ~/.zshrc) so pyenv can work properly.
eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"
Restart the shell or execute the command above. Then use following command to start the working environment.
pyenv activate faceswap-env
- Now change the directory to the place you want Faceswap program to be downloaded.
cd ~/Downloads git clone https://github.com/deepfakes/faceswap.git
- Activate your working environment (for every new terminal session you have to do this. )
- Change the directory to faceswap directory
- Run the install script and follow the instructions.
- setup plaidml(if you use GPU)
# setup plaidml to choose the GPU. python setup.py plaidml-setup
Now you can test if your setup works with a directory of images or a video file.
python faceswap extract -i INPUT_DIRECTORY -o OUTPUT_DIRECTORY
Your plaidml might not be set to the device of the most powerful GPU you plan to use. Use plaidml-setup command to set it correctly. If you are running nVidia card on MacOS 10.13.*, you can also use plaidml instead of building tensorflow for GPU by yourself.