DeepFaceLab

On this page 7

DeepFaceLab is an open-source face-swapping framework that trains a neural network on footage of two people and then replaces the face of one with the face of the other in video. In generative media, it is the best-known tool for producing high-resolution video deepfakes on consumer hardware, and it has been used for film visual effects, satire, research and, controversially, non-consensual content.

The project was started by the developer known as iperov around 2018, published as a TensorFlow-based Python codebase with prebuilt Windows packages, and described in a 2020 research paper. Development stopped and the repository was archived in 2023, but the software and its many forks remain widely used, and its workflow still shapes how practitioners think about offline face swap.

How DeepFaceLab swaps faces

DeepFaceLab follows a three-stage pipeline: extraction, training and merging. Each stage is run through numbered batch scripts, which gives the user explicit control over every intermediate result instead of a single opaque button.

During extraction, the tool splits the source video (the face to insert) and the destination video (the footage to modify) into frames, detects faces, estimates facial landmarks and saves aligned face crops. Training then fits an autoencoder with a shared encoder and separate decoders: the encoder learns a common representation of pose, expression and lighting, while each decoder learns to reconstruct one identity. At merge time, destination faces are encoded and decoded with the source decoder, then blended back into the original frames.

The table below summarizes what each stage does and what typically goes wrong there.

StageMain operationsCommon problem
ExtractionFrame splitting, face detection, landmark alignmentMisaligned or wrongly detected faces
MaskingXSeg segmentation of the face regionHair, hands or glasses leaking into the mask
TrainingAutoencoder learns both identitiesBlurry output from too few iterations
MergingFace reconstruction, color transfer, blendingVisible seams or color mismatch
ExportFrames reassembled into videoFlicker between consecutive frames
Stages of the DeepFaceLab workflow

Model types and key training parameters

DeepFaceLab offers several model architectures that differ in quality, speed and memory use. The most widely used is SAEHD, a configurable model for high-definition results; Quick96 is a lightweight model for testing, and AMP was added later to transfer more of the source face shape.

ModelTypical resolutionPurpose
Quick9696 pxFast preview on modest graphics cards
SAEHD128 to 512 pxMain model for production-quality swaps
AMP224 px and aboveStronger transfer of source face structure
Main DeepFaceLab model types

Quality depends mostly on face resolution, face type, training iterations and data variety. A higher resolution needs more video memory, and practitioners commonly train for hundreds of thousands of iterations, which can take from several days to a few weeks on a single consumer GPU. The face type setting decides how much of the head is replaced, from the central face to the whole face or full head.

ParameterEffect when increasedCost
ResolutionSharper skin and eye detailMuch higher VRAM use
Encoder and decoder dimensionsMore capacity for fine detailSlower training
Batch sizeMore stable gradientsHigher VRAM use
GAN powerCrisper textureRisk of artifacts and instability
Source set varietyBetter coverage of angles and lightingMore collection and cleanup work
Parameters that most affect the result

DeepFaceLab compared with other face tools

DeepFaceLab is a per-pair trained tool: a new model must be trained for every combination of identities. Newer approaches use one-shot face swap models that need only a single image of the source person, at the price of lower fidelity in difficult scenes. Face reenactment differs again, because it transfers expressions while keeping the original identity.

ApproachData neededSpeedTypical fidelity
DeepFaceLabMinutes of video of both peopleDays of trainingHigh for matched footage
One-shot face swapOne source imageNear real timeModerate
DeepFaceLivePretrained per-identity modelReal timeModerate to high
Face reenactmentOne target image or videoFastVaries with motion range
Position of DeepFaceLab among related techniques

DeepFaceLive, also by iperov, reuses models trained in DeepFaceLab for live webcam streams. Diffusion-based video generators can now synthesize faces from text, but DeepFaceLab remains preferred when an editor needs frame-accurate control over existing footage.

Practical requirements and workflow choices

Good results depend on matching source and destination material more than on any single setting. Practitioners aim for several thousand clean source faces that cover the head angles, expressions and lighting of the destination clip, and they remove blurred or occluded frames before training.

  • Hardware: an NVIDIA GPU with at least 8 GB of VRAM is the practical minimum for SAEHD; 12 to 24 GB allows higher resolutions.
  • Pretraining: starting from a pretrained model shortens training noticeably.
  • Masking: labeling a few hundred frames for XSeg prevents hands and hair from being overwritten.
  • Post-production: final grading, grain matching and compositing are usually done in a video editor.

Risks, ethics and detection

DeepFaceLab’s accessibility made it a central tool in the spread of non-consensual intimate deepfakes and political impersonation, which is the main reason the software is controversial. The project documentation asked users to respect consent, but an open-source tool cannot enforce how it is used.

Legal duties are increasing. The EU AI Act requires that deployers disclose deepfake content, and many jurisdictions now criminalize sexual deepfakes made without consent. Detection research targets artifacts typical of autoencoder swaps, such as blending boundaries, inconsistent lighting and unstable eye detail, although well-made swaps can evade casual inspection. Responsible professional use combines written consent, clear labeling and provenance metadata.

A plain-language summary

DeepFaceLab is a free program that puts one person’s face onto another person’s body in a video. You give it many video clips of both people. The computer studies both faces for days. Then it redraws the face in every frame.

Think of a skilled portrait painter who has watched two actors for weeks. The painter can repaint every frame so that one actor seems to wear the other’s face. The result can look very real, which is why it is useful for films and also why it can be misused.

An example from practice

A small visual effects studio worked on an independent feature in which a stunt performer doubled for the lead actor in a 40-second motorcycle sequence. Reshooting with the actor was not possible, so the team decided to use DeepFaceLab with the written consent of both performers.

The artists gathered about 15 minutes of interview and rehearsal footage of the actor, extracted roughly 6,000 usable source faces and trained an SAEHD model at 320 px with the whole-face type on a 24 GB graphics card for about ten days. They labeled 400 frames for XSeg masking so that the helmet visor and gloves stayed untouched, then finished the shots with grain matching and color grading.

The swapped shots passed review by the director and the distributor, and the end credits stated that face replacement technology had been used. The studio estimated that the work cost a fraction of a reshoot.