# iperov/deepfacelive architecture

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

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

## Overview

DeepFaceLive is a desktop application for live or video-based face swapping and face animation, with model configuration and frame output. Users launch the app, choose a camera or video source, configure face processing, and view or stream the result. The README also documents DFM-model swaps, single-photo Insight swaps, and video-controlled animation. The graph preserves those product branches; detailed runtime wiring is only partially evidenced by the supplied excerpts, so uncertain processing links are dashed and uncited.

Main entry points: [`apps/DeepFaceLive/backend/FaceAligner.py`](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceAligner.py) (Face Aligner), [`apps/DeepFaceLive/DeepFaceLiveApp.py`](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/DeepFaceLiveApp.py) (App Window), [`apps/DeepFaceLive/backend/FaceMerger.py`](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceMerger.py) (Face Merger), [`apps/DeepFaceLive/backend/FaceSwapDFM.py`](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceSwapDFM.py) (DFM Swap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and UI"]
  node_app_entry["App Window<br/>[DeepFaceLiveApp.py]"]
  node_controls["Backend Controls"]
end

subgraph group_media["Media Processing"]
  node_camera["Camera Source<br/>[CameraSource.py]"]
  node_file["File Source<br/>[FileSource.py]"]
  node_adjust["Frame Adjuster<br/>[FrameAdjuster.py]"]
  node_detect["Face Detector<br/>[FaceDetector.py]"]
  node_mark["Face Marker<br/>[FaceMarker.py]"]
  node_align["Face Aligner<br/>[FaceAligner.py]"]
  node_merge["Face Merger<br/>[FaceMerger.py]"]
  node_swap_dfm["DFM Swap<br/>[FaceSwapDFM.py]"]
  node_swap_insight["Insight Swap<br/>[FaceSwapInsight.py]"]
  node_animator["Face Animator<br/>[FaceAnimator.py]"]
  node_output["Stream Output<br/>[StreamOutput.py]"]
end

subgraph group_models["Models and Inference"]
  node_dfm_model["DFM Model<br/>[DFMModel.py]"]
  node_onnx_models["ONNX Models"]
  node_torch_models["Torch Models"]
  node_ort["ONNX Runtime"]
end

subgraph group_support["Shared Runtime"]
  node_localization["Localization<br/>[localization.py]"]
  node_fonts["Font Database<br/>[QXFontDB.py]"]
  node_image["Image Processing<br/>[ImageProcessor.py]"]
  node_landmarks["Face Geometry<br/>[FLandmarks2D.py]"]
  node_affine["Affine Math<br/>[Affine2DMat.py]"]
end

node_user(("User"))

node_user -->|"launches"| node_app_entry
node_app_entry -->|"sets language"| node_localization
node_app_entry -->|"uses fonts"| node_fonts
node_app_entry -.->|"presents controls"| node_controls
node_user -.->|"selects camera"| node_camera
node_user -.->|"selects video"| node_file
node_camera -.->|"supplies frames"| node_adjust
node_file -.->|"supplies frames"| node_adjust
node_adjust -.->|"passes frames"| node_detect
node_detect -.->|"passes faces"| node_mark
node_mark -.->|"passes landmarks"| node_align
node_align -.->|"prepares faces"| node_swap_dfm
node_align -.->|"prepares faces"| node_swap_insight
node_align -.->|"prepares faces"| node_animator
node_swap_dfm -.->|"provides swapped face"| node_merge
node_swap_insight -.->|"provides swapped face"| node_merge
node_animator -.->|"provides animated face"| node_merge
node_merge -.->|"passes result"| node_output
node_swap_dfm -.->|"uses model"| node_dfm_model
node_dfm_model -->|"creates session"| node_ort
node_dfm_model -->|"resizes output"| node_image
node_swap_insight -.->|"uses model"| node_onnx_models
node_animator -.->|"uses model"| node_onnx_models
node_align -.->|"uses model"| node_torch_models
node_landmarks -->|"uses transforms"| node_affine

click node_app_entry "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/DeepFaceLiveApp.py"
click node_controls "https://github.com/iperov/deepfacelive/tree/master/apps/DeepFaceLive/ui/widgets"
click node_camera "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/CameraSource.py"
click node_file "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FileSource.py"
click node_adjust "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FrameAdjuster.py"
click node_detect "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceDetector.py"
click node_mark "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceMarker.py"
click node_align "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceAligner.py"
click node_merge "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceMerger.py"
click node_swap_dfm "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceSwapDFM.py"
click node_swap_insight "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceSwapInsight.py"
click node_animator "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceAnimator.py"
click node_output "https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/StreamOutput.py"
click node_dfm_model "https://github.com/iperov/deepfacelive/blob/master/modelhub/DFLive/DFMModel.py"
click node_onnx_models "https://github.com/iperov/deepfacelive/tree/master/modelhub/onnx"
click node_torch_models "https://github.com/iperov/deepfacelive/tree/master/modelhub/torch"
click node_ort "https://github.com/iperov/deepfacelive/blob/master/xlib/onnxruntime/InferenceSession.py"
click node_localization "https://github.com/iperov/deepfacelive/blob/master/localization/localization.py"
click node_fonts "https://github.com/iperov/deepfacelive/blob/master/resources/fonts/QXFontDB.py"
click node_image "https://github.com/iperov/deepfacelive/blob/master/xlib/image/ImageProcessor.py"
click node_landmarks "https://github.com/iperov/deepfacelive/blob/master/xlib/face/FLandmarks2D.py"
click node_affine "https://github.com/iperov/deepfacelive/blob/master/xlib/math/Affine2DMat.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_entry,node_controls,node_user toneBlue
class node_camera,node_file,node_adjust,node_detect,node_mark,node_align,node_merge,node_swap_dfm,node_swap_insight,node_animator,node_output toneAmber
class node_dfm_model,node_onnx_models,node_torch_models,node_ort toneMint
class node_localization,node_fonts,node_image,node_landmarks,node_affine toneRose
```

## Components

### Application and UI

- [App Window](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/DeepFaceLiveApp.py): `apps/DeepFaceLive/DeepFaceLiveApp.py`
- [Backend Controls](https://github.com/iperov/deepfacelive/tree/master/apps/DeepFaceLive/ui/widgets): `apps/DeepFaceLive/ui/widgets`

### Media Processing

- [Camera Source](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/CameraSource.py): `apps/DeepFaceLive/backend/CameraSource.py`
- [File Source](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FileSource.py): `apps/DeepFaceLive/backend/FileSource.py`
- [Frame Adjuster](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FrameAdjuster.py): `apps/DeepFaceLive/backend/FrameAdjuster.py`
- [Face Detector](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceDetector.py): `apps/DeepFaceLive/backend/FaceDetector.py`
- [Face Marker](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceMarker.py): `apps/DeepFaceLive/backend/FaceMarker.py`
- [Face Aligner](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceAligner.py): `apps/DeepFaceLive/backend/FaceAligner.py`
- [Face Merger](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceMerger.py): `apps/DeepFaceLive/backend/FaceMerger.py`
- [DFM Swap](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceSwapDFM.py): `apps/DeepFaceLive/backend/FaceSwapDFM.py`
- [Insight Swap](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceSwapInsight.py): `apps/DeepFaceLive/backend/FaceSwapInsight.py`
- [Face Animator](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/FaceAnimator.py): `apps/DeepFaceLive/backend/FaceAnimator.py`
- [Stream Output](https://github.com/iperov/deepfacelive/blob/master/apps/DeepFaceLive/backend/StreamOutput.py): `apps/DeepFaceLive/backend/StreamOutput.py`

### Models and Inference

- [DFM Model](https://github.com/iperov/deepfacelive/blob/master/modelhub/DFLive/DFMModel.py): `modelhub/DFLive/DFMModel.py`
- [ONNX Models](https://github.com/iperov/deepfacelive/tree/master/modelhub/onnx): `modelhub/onnx`
- [Torch Models](https://github.com/iperov/deepfacelive/tree/master/modelhub/torch): `modelhub/torch`
- [ONNX Runtime](https://github.com/iperov/deepfacelive/blob/master/xlib/onnxruntime/InferenceSession.py): `xlib/onnxruntime/InferenceSession.py`

### Shared Runtime

- [Localization](https://github.com/iperov/deepfacelive/blob/master/localization/localization.py): `localization/localization.py`
- [Font Database](https://github.com/iperov/deepfacelive/blob/master/resources/fonts/QXFontDB.py): `resources/fonts/QXFontDB.py`
- [Image Processing](https://github.com/iperov/deepfacelive/blob/master/xlib/image/ImageProcessor.py): `xlib/image/ImageProcessor.py`
- [Face Geometry](https://github.com/iperov/deepfacelive/blob/master/xlib/face/FLandmarks2D.py): `xlib/face/FLandmarks2D.py`
- [Affine Math](https://github.com/iperov/deepfacelive/blob/master/xlib/math/Affine2DMat.py): `xlib/math/Affine2DMat.py`

### Other components

- **User**

## Connections

- User → App Window: launches
- App Window → Localization: sets language (evidence: `apps/DeepFaceLive/DeepFaceLiveApp.py`)
- App Window → Font Database: uses fonts (evidence: `apps/DeepFaceLive/DeepFaceLiveApp.py`)
- App Window → Backend Controls: presents controls (evidence: `apps/DeepFaceLive/DeepFaceLiveApp.py`)
- User → Camera Source: selects camera
- User → File Source: selects video
- Camera Source → Frame Adjuster: supplies frames
- File Source → Frame Adjuster: supplies frames
- Frame Adjuster → Face Detector: passes frames
- Face Detector → Face Marker: passes faces
- Face Marker → Face Aligner: passes landmarks
- Face Aligner → DFM Swap: prepares faces
- Face Aligner → Insight Swap: prepares faces
- Face Aligner → Face Animator: prepares faces
- DFM Swap → Face Merger: provides swapped face
- Insight Swap → Face Merger: provides swapped face
- Face Animator → Face Merger: provides animated face
- Face Merger → Stream Output: passes result
- DFM Swap → DFM Model: uses model
- DFM Model → ONNX Runtime: creates session (evidence: `modelhub/DFLive/DFMModel.py`)
- DFM Model → Image Processing: resizes output (evidence: `modelhub/DFLive/DFMModel.py`)
- Insight Swap → ONNX Models: uses model
- Face Animator → ONNX Models: uses model
- Face Aligner → Torch Models: uses model
- Face Geometry → Affine Math: uses transforms (evidence: `xlib/face/FLandmarks2D.py`)
