deepfakes/faceswap
Faceswap
Faceswap is a comprehensive framework for automated media manipulation and neural face synthesis. It provides a modular pipeline that manages the entire lifecycle of facial feature extraction, deep learning model training, and image conversion. By coordinating complex computer vision workflows, the system enables users to map facial identities between source and destination datasets while maintaining structural alignment and lighting consistency across video frames.
The project distinguishes itself through a highly extensible plugin-based architecture that handles hardware-accelerated processing and multi-stage image post-processing. It includes specialized tools for manual alignment verification, allowing users to refine detected facial data through a graphical interface to ensure high-quality results. The system also features robust batch-oriented data processing, which partitions media into standardized chunks to optimize memory usage and throughput during intensive neural network operations.
Beyond its core synthesis capabilities, the framework covers a broad range of computer vision tasks including facial landmark detection, pose estimation, and mask generation. It integrates sophisticated model management utilities, such as automated loss calculation, gradient clipping, and snapshot recovery, to ensure stable training sessions. The system also provides extensive diagnostic tools for hardware performance monitoring and environment validation, ensuring compatibility across various compute accelerators.
The software is managed through a centralized command-line and graphical toolkit that supports persistent configuration and session state management. It is designed to run on diverse hardware configurations by dynamically querying available compute resources and routing tensor operations to the optimal processor.
Features
- Face Swapping Engines - DeepFaceLab applies trained models to video frames using configured output sizes, coverage ratios, and post-processing adjustments for color and masking.
- Automated Face Swapping - Applying trained models to swap facial features across video frames while maintaining consistent lighting and structural alignment.
- Face Data Extraction - DeepFaceLab detects and aligns faces from source media, with options to save alignment data and draw debug landmarks on output images.
- Face Detection - DeepFaceLab identifies faces in frames using detection models, applying rotation and size thresholds to filter valid face detections.
- Face Landmark Alignment - DeepFaceLab calculates facial landmarks and transformation matrices to generate standardized images from video frames based on specific centering and size requirements.
- Face Tracking - DeepFaceLab stores and organizes detected face information including bounding box coordinates, facial landmarks, generated masks, and identity embeddings for subsequent processing.
- Facial Feature Extraction - Identifying and normalizing facial landmarks and spatial orientation from video frames to prepare data for machine learning pipelines.
- Identity Feature Extraction - DeepFaceLab generates identity features from faces using deep learning models to enable recognition and identity-based processing.
- Vision Pipeline Orchestrators - Coordinating complex workflows involving data ingestion, hardware-accelerated processing, and multi-stage image post-processing tasks.
- Face Masking Plugins - DeepFaceLab applies masking plugins to face patches while enforcing boundary constraints to ensure masks remain within the face area.
- Facial Analysis Tools - A collection of specialized algorithms for landmark detection, pose estimation, and mask generation used in facial analysis workflows.
- Face Alignment Tools - DeepFaceLab formats face patches for recognition by applying landmark extraction models to detected faces.
- Face Swap Plugins - DeepFaceLab coordinates face extraction, model training, and image conversion using modular plugins for color balancing, masking, and output writing.
- Neural Network Trainers - Iterating on neural network architectures to learn identity representations and facial transformations from large image datasets.
- Face Frame Converters - DeepFaceLab swaps faces in source frames using a trained model and user-selected post-processing plugins to generate final output.
- Neural Face Synthesis Engines - A machine learning environment that trains generative models to map facial identities between source and destination image sets.
- Media Processing Pipelines - A modular framework that automates the extraction, training, and synthesis of facial features within video and image datasets.
- Dataset Loaders - DeepFaceLab loads and shuffles training datasets from disk, supporting multi-input models and static or random preview image selection.
- Training Data Collation - DeepFaceLab prepares batches of training data by applying masks and formatting tensors for model input.
- Face Swapping Models - DeepFaceLab trains a face swapping model using source and destination face sets, with an integrated preview interface for monitoring progress.
- Loss Functions - DeepFaceLab computes and collates weighted loss functions for training batches, supporting mask application and loss scalar management for backpropagation.
- Training Loop Managers - DeepFaceLab executes the core training loop by managing batch processing, model saving, and the generation of preview data.
- Learning Rate Schedulers - DeepFaceLab adjusts the model learning rate over a specified number of iterations to stabilize training during the initial phase.
- Automated Media Processing Suites - A command-line and graphical toolkit that manages the lifecycle of video frame extraction, alignment, and final output reconstruction.
- Video File Processors - DeepFaceLab extracts frames from video, generates video from frames, and retrieves metadata using a simplified interface for media tasks.
- Media Alignment Managers - DeepFaceLab handles media alignments and image loading for processing, including support for video files and folder-based image sources.
- Video Muxing - DeepFaceLab combines processed video streams into new files using specified codecs, with options to include or exclude original audio tracks.
- Command Line Argument Parsers - DeepFaceLab defines command line parameters for extraction, conversion, and training tasks by specifying required and optional inputs for each operation.
- Argument Injection Systems - A centralized configuration system maps user-defined inputs to specific module parameters to control application behavior and task execution.
- Face Re-extraction Tools - DeepFaceLab generates new face images from original source frames using existing alignment data and updated parameters.
- Face Normalization - DeepFaceLab normalizes input images by applying landmark detection and filtering results based on predicted facial features within the extraction pipeline.
- Face Masking Utilities - DeepFaceLab loads existing mask images from disk into an alignment file to associate them with specific faces or frames.
- Manual Alignment Verification Tools - Reviewing and refining detected facial data through graphical interfaces to ensure high-quality results in automated processing tasks.
- Face Annotation Interfaces - DeepFaceLab displays detected faces in a graphical interface with optional overlays like masks and meshes for manual verification.
- Alignment Data Managers - DeepFaceLab reads and modifies serialized data files that store frame-level information including bounding boxes, facial landmarks, masks, and video metadata.
- Batch Processing Engines - Input media is partitioned into standardized chunks to optimize memory usage and throughput during neural network inference and training.
- Extraction Pipeline Execution - DeepFaceLab executes extraction plugin runners to manage data flow between plugins and provide methods for flushing the pipeline or retrieving results.
- Batch Processing Utilities - DeepFaceLab performs batch operations on aligned face data by adjusting normalized matrices and extracting specific face regions from source images.
- Data Iterators - DeepFaceLab processes data batches within the extraction pipeline by serving as a base class for plugins to ingest and pass information.
- Extraction Data Structures - DeepFaceLab creates data structures for batches moving through extraction pipelines, including frame metadata, image arrays, and alignment status.
- Data Augmentation - DeepFaceLab applies color, transformation, and warping adjustments to training images to improve model robustness and generalization.
- Face Pose Estimators - DeepFaceLab calculates 3D spatial orientation from facial landmarks by projecting points into 2D space and determining pitch from rotation vectors.
- Face Mask Blenders - DeepFaceLab smooths the edges of a swapped face with the original image using custom mask types for seamless integration.
- Face Mask Generation - DeepFaceLab creates single-channel masks from landmark points or applies filters to existing masks for refined face processing.
- Model Checkpointing Systems - DeepFaceLab backs up and restores training states at specific intervals to ensure progress is saved and recoverable during long training sessions.
- Model Compilation - DeepFaceLab converts a trained model into an inference-ready version by calculating required layers and configuring the swap direction.
- Model Recovery Utilities - DeepFaceLab recovers a model from a backup file to restore training progress or revert to a previous stable state.
- Model Export Utilities - DeepFaceLab exports a trained model to an inference-ready file to enable faster execution or deployment.
- Extraction Plugin Coordinators - DeepFaceLab manages the execution of extraction plugins by coordinating pre-processing, processing, and post-processing actions including model compilation.
- Real-time Media Previews - DeepFaceLab adjusts conversion settings in real-time using a graphical interface before committing to a full conversion process.
- Compute Resource Selectors - The system queries available compute resources and configures environment variables to route tensor operations to the optimal processor.
- Perceptual Loss - DeepFaceLab measures similarity between images using pretrained feature layers to improve training quality based on human visual perception.
- Training Configurations - DeepFaceLab sets training parameters including batch size, image augmentation, and snapshot intervals to control the model training process.
- Training Previews - DeepFaceLab creates and displays preview images or timelapses from model predictions and targets, with optional mask overlays for verification.
- Background Task Runners - DeepFaceLab executes generator functions in a background thread to pre-fetch data, allowing the main thread to consume items without waiting.
- Worker Thread Managers - Background threads manage heavy I/O and data pre-fetching to keep the main application responsive during intensive processing.
- Configuration Synchronizers - DeepFaceLab syncs application settings with external files by loading, formatting, and saving data to maintain state across different sessions.
- Application Settings Management - DeepFaceLab organizes application configuration by defining sections, setting default values, and validating inputs against data types before saving to persistent storage.
- Configuration Schemas - DeepFaceLab establishes configuration settings with strict data types, default values, and validation rules to ensure consistent and correctly typed application behavior.
- Face Color Adjustments - DeepFaceLab modifies the color channels of a swapped face to match the original frame using color transfer and balancing algorithms.
- Image Sorting Utilities - DeepFaceLab groups folders of face images based on criteria like blur levels or facial orientation using a configurable batch process.
- Face Metadata Loaders - DeepFaceLab retrieves aligned face images and associated metadata from disk for use in processing workflows.
- Layer Implementations - DeepFaceLab applies architectural blocks like attention pooling or bottlenecks to input tensors to extract features or process spatial grids.
- Learning Rate Schedulers - DeepFaceLab discovers the best learning rate for a training session by smoothing loss values and monitoring progress over time.
- Converted Output Writers - DeepFaceLab saves converted frames to output formats including video files or image sequences using specialized writer plugins.
- Pipeline Plugin Systems - Modular components are dynamically loaded to handle specific stages of image processing, model training, and data extraction tasks.
- Configuration Schemas - DeepFaceLab loads and manages extraction settings from initialization files to customize plugin behavior and processing parameters.
- Extraction Plugins - DeepFaceLab creates custom extraction plugins by inheriting from a base class that defines standard interfaces for batch processing and device management.
- Processing Plugin Managers - DeepFaceLab retrieves, lists, or identifies default plugins for extraction or conversion tasks within the processing pipeline.
- Process Queue Managers - DeepFaceLab coordinates thread-safe queues across multiple processes with a global shutdown event to ensure clean termination when the application stops.
- Application Script Runners - DeepFaceLab executes application scripts by loading necessary modules and passing validated arguments while monitoring for errors and ensuring clean process termination.
- Alignment Metadata Management - DeepFaceLab adds metadata such as masks or identity fields to alignment files based on processed face images.
- Face Alignment Management Tools - DeepFaceLab performs operations such as checking, sorting, and exporting extracted faces or frames outside of the core processing pipeline.
- Manual Annotation Management - DeepFaceLab converts raw files into editable objects and updates face information dynamically as manual adjustments are applied.
- Graphical Interface Launchers - DeepFaceLab opens a graphical user interface to configure and execute face swapping tasks with visual controls for settings and management.
- Gradient Optimization Techniques - DeepFaceLab adjusts model gradients during training based on historical norm data to prevent instability and ensure a smooth learning process.
- Plugin Model Managers - DeepFaceLab compiles neural network models and performs utility operations like searching for modules or generating random input arrays for testing.
- Training Metrics - DeepFaceLab records training events and visualizes model performance metrics by parsing event files during live training sessions.
- Machine Learning Environment Checkers - DeepFaceLab verifies environment compatibility by detecting installed machine learning libraries and hardware acceleration versions on the host system.