How deepfakes/faceswap works
FaceSwap is a face-swapping application whose documented workflow is to extract faces from source media, train a model on faces from two identities, then convert target media with that model. The graph separates those domain stages and shows shared inference, alignment, and media handling where the source index supports relationships. It also preserves GUI access, manual alignment, and video tooling as product capabilities. Some stage-level connections come from the README; unsampled implementation details are not inferred.
Main entry points: faceswap.py CLI entry · train.py Training loop · convert.py Conversion engine · handler.py Inference handlers
Components 22
Face extraction
- Extract command
scripts/extract.py - Detection and alignment plugins
plugins/extract/base.py
Model training
- Training command
scripts/train.py - Training loop
lib/training/train.py - Training data
lib/training/data/data_set.py - Model architectures
plugins/train/model/phaze_a.py - Trainer implementations
plugins/train/trainer/base.py
Face conversion
- Convert command
scripts/convert.py - Conversion engine
lib/convert.py - Swap and output plugins
plugins/convert/color/color_transfer.py
Shared runtime
- Inference handlers
lib/infer/handler.py - Plugin loader
plugins/plugin_loader.py - Face alignment data
lib/align/aligned_face.py - Alignment files
lib/align/alignments.py - Image and video I/O
lib/image.py - Inference runner
lib/infer/runner.py
User interfaces and tools
- CLI entry
faceswap.py - Graphical interface
scripts/gui.py - Swap preview
tools/preview/preview.py - Manual face tools
tools/manual/manual.py - Video tools
tools/effmpeg/effmpeg.py
Other components
- User
Connections 22
- User → CLI entry: runs
README.md - CLI entry → Extract command: starts extraction
README.md - CLI entry → Training command: starts training
README.md - CLI entry → Convert command: starts conversion
README.md - CLI entry → Graphical interface: opens GUI
README.md - Extract command → Detection and alignment plugins: uses plugins
- Detection and alignment plugins → Inference handlers: handled by
lib/infer/handler.py - Inference handlers → Plugin loader: loads plugins
lib/infer/handler.py - Inference handlers → Inference runner: managed by
lib/infer/handler.py - Inference handlers → Face alignment data: creates aligned faces
lib/infer/handler.py - Extract command → Alignment files: saves alignments
- Training command → Training loop: starts training
- Training loop → Training data: uses datasets
- Training loop → Model architectures: trains model
- Training loop → Trainer implementations: uses trainer
- Convert command → Conversion engine: runs conversion
tools/preview/preview.py - Conversion engine → Inference runner: uses inference
- Conversion engine → Swap and output plugins: uses plugins
- Conversion engine → Image and video I/O: processes media
- Graphical interface → Swap preview: offers preview
- User → Manual face tools: edits faces
- User → Video tools: runs video tools
README.md