The previous article introduced how to do a face swap with the Deepfake repository. Deepfake evolutes very fast, previous tricks depend on the alignment file that does not work anymore.
A more intuitive tool -DeepFaceLab which claims 90% of face swapping works on the internet were done by the tool.
In the previous article, the acceleration depends on PlaidML which used OpenCL. As Apple started supporting TensorFlow and PyTorch metal, making the tool compatible with macOS is easier.
What we provide here:
- An introduction to how to prepare the environment from ground-up for M1 Mac. A simple script is provide to install all required packages. The script does not work on Intel platform. It needs some modifications.
- How to import faces, correct them ,and export to DeepFaceLab for their process.
- How to prepare a movie, and throw the extracted frames to DeepFaceLab. How to merge it back after the materials are processed.
If you follow the steps to install DeepFaceLab, it should work without Scene Selector. A complete guide I can find on the web is https://www.deepfakevfx.com/guides/deepfacelab-2-0-guide/. There are some limitations:
- Apple’s MPS support is not complete and there are bugs to be fixed. I have to move some operations to the CPU. It surely slows down the process. Running on GPU is only about 5-6 times faster than it on CPU. It’s a sign that GPU is not fully optimized( or the CPU is too fast?)
- Only 32-bit data is supported in MPS, which slows down the training process. More ram is required to support higher resolution. Sometimes, 32G of system memory is barely enough.
- Though GPU performance for M1 Pro and M1 Max looks good in some tests, M1 Max 32 cores GPU is only comparable to the card like RTX3060 at the SAME power level. M1 Max GPU consumes 40W at its peak performance, and RTX could reach 8 times more.
Begin the Journey
I tried to make the installation process as simple as possible. It should work without much interaction even starting from a fresh system, but you still need to look out for some errors during the installation.
Fast clone the main script, and open Terminal(launch from Launchpad). Change the directory via the ”cd” command to where you want it to be installed and type
git clone https://github.com/julianko13/DeepFaceLab_Mac_M1.git
You can add a folder name if you don’t want to use the default name “DeepFaceLab_Mac_M1”.
If git is not available, the system will ask to install the Xcode Command Line tool. Follow the instruction and install it.
After successfully cloning the source, enter the directory
Run the script.
You may need to respond to the terminal if brew is not previously installed. There are >1GB of files to be downloaded and installed. Be patient. If the terminal shows any critical errors, such as cloning interrupted for network problems, just re-run the script to fix it.
Once done, you are ready to go to the next step.