# mk-minchul/adaface architecture

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

- Interactive diagram: https://gitdiagram.com/mk-minchul/adaface
- Repository: https://github.com/mk-minchul/adaface

## Overview

AdaFace is a face-recognition research implementation centered on quality-adaptive margin training and face-embedding inference. The training workflow configures a trainer and data module, loads and augments face data, and learns embeddings with a backbone and AdaFace head. Inference aligns faces before embedding them; separate evaluation branches assess IJB-S and TinyFace, and IJB-B/C using dataset-specific protocols. The README also documents pretrained models and evaluation across four benchmarks. Relationships reflect the README and source-index references; unsampled implementation details and uncertain wiring are omitted.

Main entry points: [`net.py`](https://github.com/mk-minchul/adaface/blob/master/net.py) (Embedding backbone), [`validation_mixed/validate_IJB_BC.py`](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/validate_IJB_BC.py) (IJB-B/C runner), [`face_alignment/mtcnn.py`](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn.py) (MTCNN detector), [`train_val.py`](https://github.com/mk-minchul/adaface/blob/master/train_val.py) (Trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training"]
  node_main["Training entry<br/>[main.py]"]
  node_trainer["Trainer<br/>[train_val.py]"]
  node_data_module["Data module<br/>[data.py]"]
  node_folder_data["Image datasets"]
  node_record_data["Record datasets<br/>[record_dataset.py]"]
  node_augmenter["Augmentations<br/>[augmenter.py]"]
end

subgraph group_recognition["Recognition"]
  node_backbone["Embedding backbone<br/>[net.py]"]
  node_adaface_head["AdaFace loss head<br/>[head.py]"]
  node_inference["Embedding inference<br/>[inference.py]"]
end

subgraph group_alignment["Face alignment"]
  node_align_entry["Alignment API<br/>[align.py]"]
  node_mtcnn["MTCNN detector<br/>[mtcnn.py]"]
  node_mtcnn_nets["Detector networks<br/>[get_nets.py]"]
  node_mtcnn_stages["Detection stages<br/>[first_stage.py]"]
  node_mtcnn_boxes["Box utilities<br/>[box_utils.py]"]
  node_alignment_transform["Face transforms<br/>[align_trans.py]"]
end

subgraph group_eval_lq["Low-quality evaluation"]
  node_eval_utils["Evaluation utilities<br/>[evaluate_utils.py]"]
  node_lq_data["LQ benchmark data<br/>[data_utils.py]"]
  node_ijbs_eval["IJB-S protocols<br/>[evaluate_helper.py]"]
  node_ijbs_templates["IJB-S templates<br/>[ijbs.py]"]
  node_tinyface_eval["TinyFace evaluation<br/>[tinyface_helper.py]"]
  node_ijbs_entry["IJB-S runner<br/>[validate_IJB_S.py]"]
  node_tinyface_entry["TinyFace runner"]
end

subgraph group_eval_mixed["IJB-B/C evaluation"]
  node_mixed_entry["IJB-B/C runner<br/>[validate_IJB_BC.py]"]
  node_mixed_loader["Benchmark loader<br/>[dataloader.py]"]
  node_mixed_infer["Benchmark inference<br/>[infer_helper.py]"]
  node_mixed_eval["Verification evaluation<br/>[eval_helper.py]"]
  node_mixed_identification["Identification evaluation"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_main
node_main -->|"creates trainer"| node_trainer
node_main -->|"creates data module"| node_data_module
node_data_module -->|"uses datasets"| node_folder_data
node_data_module -->|"uses datasets"| node_record_data
node_folder_data -->|"applies augmentations"| node_augmenter
node_record_data -->|"applies augmentations"| node_augmenter
node_trainer -->|"uses model"| node_backbone
node_trainer -->|"uses loss head"| node_adaface_head
node_trainer -->|"uses evaluation"| node_eval_utils
node_user -->|"requests embeddings"| node_inference
node_inference -->|"aligns images"| node_align_entry
node_inference -->|"computes embeddings"| node_backbone
node_align_entry -->|"delegates alignment"| node_mtcnn
node_mtcnn -->|"instantiates networks"| node_mtcnn_nets
node_mtcnn -->|"runs detection stage"| node_mtcnn_stages
node_mtcnn -->|"processes boxes"| node_mtcnn_boxes
node_mtcnn -->|"warps faces"| node_alignment_transform
node_lq_data -.->|"supports embeddings"| node_backbone
node_ijbs_entry -->|"runs model"| node_backbone
node_ijbs_entry -->|"loads benchmark data"| node_lq_data
node_ijbs_entry -->|"runs evaluation"| node_ijbs_eval
node_ijbs_eval -->|"uses protocols"| node_ijbs_templates
node_tinyface_entry -->|"runs model"| node_backbone
node_tinyface_entry -->|"loads benchmark data"| node_lq_data
node_tinyface_entry -->|"runs evaluation"| node_tinyface_eval
node_mixed_entry -->|"runs model"| node_backbone
node_mixed_entry -->|"prepares data"| node_mixed_loader
node_mixed_entry -->|"uses inference"| node_mixed_infer
node_mixed_entry -->|"evaluates verification"| node_mixed_eval
node_mixed_entry -->|"evaluates identification"| node_mixed_identification
node_mixed_infer -->|"loads batches"| node_mixed_loader

click node_main "https://github.com/mk-minchul/adaface/blob/master/main.py"
click node_trainer "https://github.com/mk-minchul/adaface/blob/master/train_val.py"
click node_data_module "https://github.com/mk-minchul/adaface/blob/master/data.py"
click node_folder_data "https://github.com/mk-minchul/adaface/blob/master/dataset/image_folder_dataset.py"
click node_record_data "https://github.com/mk-minchul/adaface/blob/master/dataset/record_dataset.py"
click node_augmenter "https://github.com/mk-minchul/adaface/blob/master/dataset/augmenter.py"
click node_backbone "https://github.com/mk-minchul/adaface/blob/master/net.py"
click node_adaface_head "https://github.com/mk-minchul/adaface/blob/master/head.py"
click node_inference "https://github.com/mk-minchul/adaface/blob/master/inference.py"
click node_align_entry "https://github.com/mk-minchul/adaface/blob/master/face_alignment/align.py"
click node_mtcnn "https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn.py"
click node_mtcnn_nets "https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/get_nets.py"
click node_mtcnn_stages "https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/first_stage.py"
click node_mtcnn_boxes "https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/box_utils.py"
click node_alignment_transform "https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/align_trans.py"
click node_eval_utils "https://github.com/mk-minchul/adaface/blob/master/evaluate_utils.py"
click node_lq_data "https://github.com/mk-minchul/adaface/blob/master/validation_lq/data_utils.py"
click node_ijbs_eval "https://github.com/mk-minchul/adaface/blob/master/validation_lq/evaluate_helper.py"
click node_ijbs_templates "https://github.com/mk-minchul/adaface/blob/master/validation_lq/PFE/ijbs.py"
click node_tinyface_eval "https://github.com/mk-minchul/adaface/blob/master/validation_lq/tinyface_helper.py"
click node_ijbs_entry "https://github.com/mk-minchul/adaface/blob/master/validation_lq/validate_IJB_S.py"
click node_tinyface_entry "https://github.com/mk-minchul/adaface/blob/master/validation_lq/validate_tinyface.py"
click node_mixed_entry "https://github.com/mk-minchul/adaface/blob/master/validation_mixed/validate_IJB_BC.py"
click node_mixed_loader "https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/dataloader.py"
click node_mixed_infer "https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/infer_helper.py"
click node_mixed_eval "https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/eval_helper.py"
click node_mixed_identification "https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/eval_helper_identification.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_main,node_trainer,node_data_module,node_folder_data,node_record_data,node_augmenter toneBlue
class node_backbone,node_adaface_head,node_inference toneAmber
class node_align_entry,node_mtcnn,node_mtcnn_nets,node_mtcnn_stages,node_mtcnn_boxes,node_alignment_transform toneMint
class node_eval_utils,node_lq_data,node_ijbs_eval,node_ijbs_templates,node_tinyface_eval,node_ijbs_entry,node_tinyface_entry toneRose
class node_mixed_entry,node_mixed_loader,node_mixed_infer,node_mixed_eval,node_mixed_identification,node_user toneIndigo
```

## Components

### Training

- [Training entry](https://github.com/mk-minchul/adaface/blob/master/main.py): `main.py`
- [Trainer](https://github.com/mk-minchul/adaface/blob/master/train_val.py): `train_val.py`
- [Data module](https://github.com/mk-minchul/adaface/blob/master/data.py): `data.py`
- [Image datasets](https://github.com/mk-minchul/adaface/blob/master/dataset/image_folder_dataset.py): `dataset/image_folder_dataset.py`
- [Record datasets](https://github.com/mk-minchul/adaface/blob/master/dataset/record_dataset.py): `dataset/record_dataset.py`
- [Augmentations](https://github.com/mk-minchul/adaface/blob/master/dataset/augmenter.py): `dataset/augmenter.py`

### Recognition

- [Embedding backbone](https://github.com/mk-minchul/adaface/blob/master/net.py): `net.py`
- [AdaFace loss head](https://github.com/mk-minchul/adaface/blob/master/head.py): `head.py`
- [Embedding inference](https://github.com/mk-minchul/adaface/blob/master/inference.py): `inference.py`

### Face alignment

- [Alignment API](https://github.com/mk-minchul/adaface/blob/master/face_alignment/align.py): `face_alignment/align.py`
- [MTCNN detector](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn.py): `face_alignment/mtcnn.py`
- [Detector networks](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/get_nets.py): `face_alignment/mtcnn_pytorch/src/get_nets.py`
- [Detection stages](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/first_stage.py): `face_alignment/mtcnn_pytorch/src/first_stage.py`
- [Box utilities](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/box_utils.py): `face_alignment/mtcnn_pytorch/src/box_utils.py`
- [Face transforms](https://github.com/mk-minchul/adaface/blob/master/face_alignment/mtcnn_pytorch/src/align_trans.py): `face_alignment/mtcnn_pytorch/src/align_trans.py`

### Low-quality evaluation

- [Evaluation utilities](https://github.com/mk-minchul/adaface/blob/master/evaluate_utils.py): `evaluate_utils.py`
- [LQ benchmark data](https://github.com/mk-minchul/adaface/blob/master/validation_lq/data_utils.py): `validation_lq/data_utils.py`
- [IJB-S protocols](https://github.com/mk-minchul/adaface/blob/master/validation_lq/evaluate_helper.py): `validation_lq/evaluate_helper.py`
- [IJB-S templates](https://github.com/mk-minchul/adaface/blob/master/validation_lq/PFE/ijbs.py): `validation_lq/PFE/ijbs.py`
- [TinyFace evaluation](https://github.com/mk-minchul/adaface/blob/master/validation_lq/tinyface_helper.py): `validation_lq/tinyface_helper.py`
- [IJB-S runner](https://github.com/mk-minchul/adaface/blob/master/validation_lq/validate_IJB_S.py): `validation_lq/validate_IJB_S.py`
- [TinyFace runner](https://github.com/mk-minchul/adaface/blob/master/validation_lq/validate_tinyface.py): `validation_lq/validate_tinyface.py`

### IJB-B/C evaluation

- [IJB-B/C runner](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/validate_IJB_BC.py): `validation_mixed/validate_IJB_BC.py`
- [Benchmark loader](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/dataloader.py): `validation_mixed/insightface_ijb_helper/dataloader.py`
- [Benchmark inference](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/infer_helper.py): `validation_mixed/insightface_ijb_helper/infer_helper.py`
- [Verification evaluation](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/eval_helper.py): `validation_mixed/insightface_ijb_helper/eval_helper.py`
- [Identification evaluation](https://github.com/mk-minchul/adaface/blob/master/validation_mixed/insightface_ijb_helper/eval_helper_identification.py): `validation_mixed/insightface_ijb_helper/eval_helper_identification.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training entry: starts training (evidence: `main.py`)
- Training entry → Trainer: creates trainer (evidence: `main.py`)
- Training entry → Data module: creates data module (evidence: `main.py`)
- Data module → Image datasets: uses datasets (evidence: `data.py`)
- Data module → Record datasets: uses datasets (evidence: `data.py`)
- Image datasets → Augmentations: applies augmentations (evidence: `dataset/image_folder_dataset.py`)
- Record datasets → Augmentations: applies augmentations (evidence: `dataset/record_dataset.py`)
- Trainer → Embedding backbone: uses model (evidence: `train_val.py`)
- Trainer → AdaFace loss head: uses loss head (evidence: `train_val.py`)
- Trainer → Evaluation utilities: uses evaluation (evidence: `train_val.py`)
- Researcher → Embedding inference: requests embeddings (evidence: `README.md`)
- Embedding inference → Alignment API: aligns images (evidence: `inference.py`)
- Embedding inference → Embedding backbone: computes embeddings (evidence: `inference.py`)
- Alignment API → MTCNN detector: delegates alignment (evidence: `face_alignment/align.py`)
- MTCNN detector → Detector networks: instantiates networks (evidence: `face_alignment/mtcnn.py`)
- MTCNN detector → Detection stages: runs detection stage (evidence: `face_alignment/mtcnn.py`)
- MTCNN detector → Box utilities: processes boxes (evidence: `face_alignment/mtcnn.py`)
- MTCNN detector → Face transforms: warps faces (evidence: `face_alignment/mtcnn.py`)
- LQ benchmark data → Embedding backbone: supports embeddings
- IJB-S runner → Embedding backbone: runs model (evidence: `validation_lq/validate_IJB_S.py`)
- IJB-S runner → LQ benchmark data: loads benchmark data (evidence: `validation_lq/validate_IJB_S.py`)
- IJB-S runner → IJB-S protocols: runs evaluation (evidence: `validation_lq/validate_IJB_S.py`)
- IJB-S protocols → IJB-S templates: uses protocols (evidence: `validation_lq/evaluate_helper.py`)
- TinyFace runner → Embedding backbone: runs model (evidence: `validation_lq/validate_tinyface.py`)
- TinyFace runner → LQ benchmark data: loads benchmark data (evidence: `validation_lq/validate_tinyface.py`)
- TinyFace runner → TinyFace evaluation: runs evaluation (evidence: `validation_lq/validate_tinyface.py`)
- IJB-B/C runner → Embedding backbone: runs model (evidence: `validation_mixed/validate_IJB_BC.py`)
- IJB-B/C runner → Benchmark loader: prepares data (evidence: `validation_mixed/validate_IJB_BC.py`)
- IJB-B/C runner → Benchmark inference: uses inference (evidence: `validation_mixed/validate_IJB_BC.py`)
- IJB-B/C runner → Verification evaluation: evaluates verification (evidence: `validation_mixed/validate_IJB_BC.py`)
- IJB-B/C runner → Identification evaluation: evaluates identification (evidence: `validation_mixed/validate_IJB_BC.py`)
- Benchmark inference → Benchmark loader: loads batches (evidence: `validation_mixed/insightface_ijb_helper/infer_helper.py`)
