# evgenyalex21/faceswap-webapp architecture

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

- Interactive diagram: https://gitdiagram.com/evgenyalex21/faceswap-webapp
- Repository: https://github.com/evgenyalex21/faceswap-webapp

## Overview

Local Face Swap is an offline Gradio application: users select source and target faces, process a photo or video, and receive a saved result; video processing can retain its audio. The UI also exposes prompt-based editing, image-to-video animation, and mask-based inpainting. Shared infrastructure handles GPU selection, VRAM pressure, prompt translation, and media I/O. The graph reflects the shown calls and documented capabilities; some internal wiring, especially video audio handling, is not visible in the excerpts.

Main entry points: [`app/main.py`](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/main.py) (Gradio UI), [`app/swapper.py`](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py) (Video swapping), [`app/utils.py`](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/utils.py) (Media utilities), [`app/editor.py`](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/editor.py) (Prompt editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Application interface"]
  node_ui["Gradio UI<br/>[main.py]"]
end

subgraph group_faceswap["Face swapping"]
  node_face_scan["Face selection<br/>[swapper.py]"]
  node_photo_swap["Photo swapping<br/>[swapper.py]"]
  node_video_swap["Video swapping<br/>[swapper.py]"]
end

subgraph group_generation["AI image tools"]
  node_editor["Prompt editor<br/>[editor.py]"]
  node_animator["Photo animation<br/>[animator.py]"]
  node_inpaint["Mask inpainting<br/>[inpaint.py]"]
  node_translator["Prompt translation<br/>[translate.py]"]
end

subgraph group_media["Media and outputs"]
  node_media_io["Media utilities<br/>[utils.py]"]
  node_outputs[("Local results<br/>[utils.py]")]
end

subgraph group_runtime["Runtime support"]
  node_gpu["CUDA detection<br/>[gpu_utils.py]"]
  node_vram["VRAM manager<br/>[vram.py]"]
end

node_user(("Local user"))

node_user -->|"uses"| node_ui
node_ui -->|"requests scans"| node_face_scan
node_ui -->|"requests photo swap"| node_photo_swap
node_ui -->|"requests video swap"| node_video_swap
node_ui -->|"requests edits"| node_editor
node_ui -->|"requests animation"| node_animator
node_ui -->|"requests inpainting"| node_inpaint
node_photo_swap -->|"selects providers"| node_gpu
node_photo_swap -.->|"uses media I/O"| node_media_io
node_video_swap -->|"selects providers"| node_gpu
node_video_swap -.->|"uses media I/O"| node_media_io
node_video_swap -.->|"saves video"| node_outputs
node_editor -->|"translates prompts"| node_translator
node_animator -->|"translates prompts"| node_translator
node_editor -->|"manages memory"| node_vram
node_animator -->|"manages memory"| node_vram
node_inpaint -->|"writes result"| node_media_io
node_translator -->|"uses model paths"| node_media_io
node_vram -->|"unloads models"| node_photo_swap
node_ui -->|"initializes diagnostics"| node_gpu

click node_ui "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/main.py"
click node_face_scan "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py"
click node_photo_swap "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py"
click node_video_swap "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py"
click node_editor "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/editor.py"
click node_animator "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/animator.py"
click node_inpaint "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/inpaint.py"
click node_translator "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/translate.py"
click node_gpu "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/gpu_utils.py"
click node_vram "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/vram.py"
click node_media_io "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/utils.py"
click node_outputs "https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/utils.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_ui,node_user toneBlue
class node_face_scan,node_photo_swap,node_video_swap toneAmber
class node_editor,node_animator,node_inpaint,node_translator toneMint
class node_media_io,node_outputs toneRose
class node_gpu,node_vram toneIndigo
```

## Components

### Application interface

- [Gradio UI](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/main.py): `app/main.py`

### Face swapping

- [Face selection](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py): `app/swapper.py`
- [Photo swapping](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py): `app/swapper.py`
- [Video swapping](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/swapper.py): `app/swapper.py`

### AI image tools

- [Prompt editor](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/editor.py): `app/editor.py`
- [Photo animation](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/animator.py): `app/animator.py`
- [Mask inpainting](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/inpaint.py): `app/inpaint.py`
- [Prompt translation](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/translate.py): `app/translate.py`

### Media and outputs

- [Media utilities](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/utils.py): `app/utils.py`
- [Local results](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/utils.py): `app/utils.py`

### Runtime support

- [CUDA detection](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/gpu_utils.py): `app/gpu_utils.py`
- [VRAM manager](https://github.com/evgenyalex21/faceswap-webapp/blob/main/app/vram.py): `app/vram.py`

### Other components

- **Local user**

## Connections

- Local user → Gradio UI: uses (evidence: `README.md`)
- Gradio UI → Face selection: requests scans (evidence: `README.md`)
- Gradio UI → Photo swapping: requests photo swap (evidence: `app/main.py`)
- Gradio UI → Video swapping: requests video swap (evidence: `app/main.py`)
- Gradio UI → Prompt editor: requests edits (evidence: `app/main.py`)
- Gradio UI → Photo animation: requests animation (evidence: `README.md`)
- Gradio UI → Mask inpainting: requests inpainting (evidence: `app/main.py`)
- Photo swapping → CUDA detection: selects providers (evidence: `app/swapper.py`)
- Photo swapping → Media utilities: uses media I/O (evidence: `app/swapper.py`)
- Video swapping → CUDA detection: selects providers (evidence: `app/swapper.py`)
- Video swapping → Media utilities: uses media I/O (evidence: `app/swapper.py`)
- Video swapping → Local results: saves video (evidence: `app/swapper.py`)
- Prompt editor → Prompt translation: translates prompts (evidence: `app/editor.py`)
- Photo animation → Prompt translation: translates prompts (evidence: `app/animator.py`)
- Prompt editor → VRAM manager: manages memory (evidence: `app/editor.py`)
- Photo animation → VRAM manager: manages memory (evidence: `app/animator.py`)
- Mask inpainting → Media utilities: writes result (evidence: `app/inpaint.py`)
- Prompt translation → Media utilities: uses model paths (evidence: `app/translate.py`)
- VRAM manager → Photo swapping: unloads models (evidence: `app/vram.py`)
- Gradio UI → CUDA detection: initializes diagnostics (evidence: `app/main.py`)
