# iperov/deepfacelab architecture

> Architecture diagram of the GitHub repository iperov/deepfacelab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iperov/deepfacelab
- Repository: https://github.com/iperov/deepfacelab

## Overview

##### Main Components

a) Core Processing Pipeline:
- Face Extraction Module (facelib/)
- Sample Processing System (samplelib/)
- Model Training System (models/)
- Merging System (merger/)

b) Supporting Systems:
- Core Framework (core/)
- User Interface Components (XSegEditor/)
- Image Processing Libraries (DFLIMG/)

**[Input] -> [Extraction] -> [Sample Processing] -> [Training] -> [Merging] -> [Output]**

##### Face Processing Core
- S3FD Face Detector
- FANExtractor (landmarks)
- XSegNet (segmentation)
- Face Enhancer

##### Deep Learning Framework
- Leras Neural Network System
- Model Architectures
- Training Infrastructure

##### Supporting Systems (Bottom)
- Image Processing Utilities
- Job Management System
- UI Components

##### Connection Types

- Double lines: API boundaries

##### Key Technical Details

a) Model Architecture Support:
- SAEHD
- Quick96
- AMP
- XSeg

b) Framework Integration:
- TensorFlow
- CUDA
- DirectX

##### Specific Implementation Notes

- Parallel processing capabilities (core/joblib/)
- Modular model system (models/)
- Interactive merger subsystem
- Sample generation pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        IN[Source Videos/Images]
    end

    subgraph "Face Processing Pipeline"
        direction TB
        FE[Face Extraction]
        SP[Sample Processing]
        MT[Model Training]
        MS[Merging System]
    end

    subgraph "Face Processing Core"
        direction TB
        S3FD[S3FD Detector]
        FAN[FAN Extractor]
        XSEG[XSegNet]
        FEnh[Face Enhancer]
    end

    subgraph "Deep Learning Framework"
        direction TB
        NN[Neural Network System]
        MA[Model Architectures]
        TI[Training Infrastructure]
    end

    subgraph "Model Types"
        direction TB
        SAEHD[SAEHD]
        Q96[Quick96]
        AMP[AMP]
        XM[XSeg]
    end

    subgraph "Supporting Systems"
        direction TB
        IPU[Image Processing Utils]
        JMS[Job Management]
        UI[User Interface]
    end

    subgraph Output
        OUT[Processed Videos/Images]
    end

    %% Main Flow
    IN --> FE
    FE --> SP
    SP --> MT
    MT --> MS
    MS --> OUT

    %% Face Processing Connections
    FE --> S3FD
    FE --> FAN
    FE --> XSEG
    FE --> FEnh

    %% DL Framework Connections
    MT --> NN
    MT --> MA
    MT --> TI

    %% Model Connections
    MT --> SAEHD
    MT --> Q96
    MT --> AMP
    MT --> XM

    %% Support System Connections
    IPU -.-> FE
    IPU -.-> SP
    IPU -.-> MS
    JMS -.-> MT
    UI -.-> MS

    %% Styling
    classDef core fill:#2374ab
    classDef processing fill:#57a773
    classDef ui fill:#ff8c42
    classDef support fill:#95a5a6
    classDef input fill:#16a085
    classDef output fill:#16a085

    class FE,SP,MT,MS processing
    class S3FD,FAN,XSEG,FEnh core
    class NN,MA,TI core
    class SAEHD,Q96,AMP,XM core
    class IPU,JMS support
    class UI ui
    class IN,OUT input

    %% Click Events
    click FE "https://github.com/iperov/DeepFaceLab/tree/master/facelib"
    click S3FD "https://github.com/iperov/DeepFaceLab/blob/master/facelib/S3FDExtractor.py"
    click FAN "https://github.com/iperov/DeepFaceLab/blob/master/facelib/FANExtractor.py"
    click FEnh "https://github.com/iperov/DeepFaceLab/blob/master/facelib/FaceEnhancer.py"
    click SP "https://github.com/iperov/DeepFaceLab/tree/master/samplelib"
    click MT "https://github.com/iperov/DeepFaceLab/tree/master/models"
    click MS "https://github.com/iperov/DeepFaceLab/tree/master/merger"
    click SAEHD "https://github.com/iperov/DeepFaceLab/tree/master/models/Model_SAEHD"
    click Q96 "https://github.com/iperov/DeepFaceLab/tree/master/models/Model_Quick96"
    click AMP "https://github.com/iperov/DeepFaceLab/tree/master/models/Model_AMP"
    click XM "https://github.com/iperov/DeepFaceLab/tree/master/models/Model_XSeg"
    click NN "https://github.com/iperov/DeepFaceLab/blob/master/core/leras/nn.py"
    click MA "https://github.com/iperov/DeepFaceLab/tree/master/core/leras/archis"
    click IPU "https://github.com/iperov/DeepFaceLab/tree/master/DFLIMG"
    click UI "https://github.com/iperov/DeepFaceLab/tree/master/XSegEditor"
    click JMS "https://github.com/iperov/DeepFaceLab/tree/master/core/joblib"
```
