# vinairesearch/anti-dreambooth architecture

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

- Interactive diagram: https://gitdiagram.com/vinairesearch/anti-dreambooth
- Repository: https://github.com/vinairesearch/anti-dreambooth

## Overview

Anti-DreamBooth protects personal photos by generating subtle adversarial perturbations intended to weaken DreamBooth personalization; users can also train and run DreamBooth models and evaluate generated images. The graph keeps the documented attack, training, inference, and evaluation branches distinct. Edges are limited to README-documented workflows and relationships visible in the supplied excerpts or SOURCE INDEX; some evaluation entry points and attack implementations were not sampled.

Main entry points: [`evaluations/deepface/deepface/DeepFace.py`](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/DeepFace.py) (Face evaluation), [`evaluations/FaceImageQuality/face_image_quality.py`](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/face_image_quality.py) (SER-FIQ scoring), [`evaluations/ism_fdfr.py`](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/ism_fdfr.py) (Identity scores), [`train_dreambooth.py`](https://github.com/vinairesearch/anti-dreambooth/blob/main/train_dreambooth.py) (DreamBooth training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_defense["Image defense"]
  node_aspl["ASPL attack<br/>[aspl.py]"]
  node_aspl_lora["ASPL LoRA<br/>[aspl_lora.py]"]
  node_ensemble_aspl["Ensemble ASPL<br/>[ensemble_aspl.py]"]
  node_fsmg["FSMG attack<br/>[fsmg.py]"]
  node_ensemble_fsmg["Ensemble FSMG<br/>[ensemble_fsmg.py]"]
  node_protected_images["Perturbed images"]
end

subgraph group_generation["DreamBooth generation"]
  node_dreambooth_train["DreamBooth training"]
  node_lora_train["LoRA training"]
  node_model["Trained model"]
  node_inference["Image inference<br/>[infer.py]"]
  node_generated_images["Generated images"]
end

subgraph group_identity["Face identity analysis"]
  node_face_eval["Face evaluation<br/>[DeepFace.py]"]
  node_face_api["Face API routes<br/>[routes.py]"]
  node_face_service["Face API service<br/>[service.py]"]
  node_face_prep["Face preprocessing<br/>[functions.py]"]
  node_face_detectors["Face detectors<br/>[FaceDetector.py]"]
  node_face_models["Embedding backbones<br/>[Facenet.py]"]
  node_deepface_attributes["Attribute models<br/>[Emotion.py]"]
  node_face_distance["Distance metrics<br/>[distance.py]"]
  node_index_embeddings["Index embeddings<br/>[compute_idx_emb.py]"]
  node_identity_scores["Identity scores<br/>[ism_fdfr.py]"]
end

subgraph group_quality["Image quality analysis"]
  node_quality_eval["SER-FIQ scoring"]
  node_mtcnn["MTCNN detection<br/>[mtcnn_detector.py]"]
  node_face_alignment["Face alignment<br/>[face_preprocess.py]"]
  node_quality_metrics["BRISQUE scoring<br/>[brisques.py]"]
  node_retinaface["RetinaFace detection<br/>[RetinaFace.py]"]
  node_retina_model["RetinaFace model"]
  node_retina_post["RetinaFace postprocess<br/>[postprocess.py]"]
end

node_user(("User"))

node_user -->|"selects defense"| node_aspl
node_user -.->|"selects defense"| node_aspl_lora
node_user -->|"selects defense"| node_ensemble_aspl
node_user -->|"selects defense"| node_fsmg
node_user -->|"selects defense"| node_ensemble_fsmg
node_aspl -->|"perturbs images"| node_protected_images
node_aspl_lora -.->|"perturbs images"| node_protected_images
node_ensemble_aspl -->|"perturbs images"| node_protected_images
node_fsmg -->|"perturbs images"| node_protected_images
node_ensemble_fsmg -->|"perturbs images"| node_protected_images
node_user -->|"provides images"| node_dreambooth_train
node_user -.->|"provides images"| node_lora_train
node_protected_images -->|"trains on"| node_dreambooth_train
node_protected_images -.->|"trains on"| node_lora_train
node_dreambooth_train -->|"trains"| node_model
node_lora_train -.->|"trains"| node_model
node_user -->|"requests generation"| node_inference
node_model -->|"loads model"| node_inference
node_inference -->|"generates"| node_generated_images
node_face_api -->|"routes requests"| node_face_service
node_face_service -->|"calls analysis"| node_face_eval
node_face_eval -->|"extracts faces"| node_face_prep
node_face_prep -->|"dispatches detection"| node_face_detectors
node_face_eval -->|"selects backbones"| node_face_models
node_face_eval -->|"loads attributes"| node_deepface_attributes
node_face_eval -->|"uses metrics"| node_face_distance
node_index_embeddings -->|"extracts embeddings"| node_face_eval
node_identity_scores -->|"extracts embeddings"| node_face_eval
node_identity_scores -->|"loads reference embedding"| node_index_embeddings
node_quality_eval -->|"detects faces"| node_mtcnn
node_quality_eval -->|"aligns faces"| node_face_alignment
node_retinaface -->|"builds model"| node_retina_model
node_retinaface -->|"processes detections"| node_retina_post
node_user -.->|"evaluates images"| node_quality_eval
node_user -.->|"evaluates images"| node_quality_metrics
node_generated_images -.->|"measures identity"| node_identity_scores
node_generated_images -.->|"measures quality"| node_quality_eval

click node_aspl "https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/aspl.py"
click node_aspl_lora "https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/aspl_lora.py"
click node_ensemble_aspl "https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/ensemble_aspl.py"
click node_fsmg "https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/fsmg.py"
click node_ensemble_fsmg "https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/ensemble_fsmg.py"
click node_dreambooth_train "https://github.com/vinairesearch/anti-dreambooth/blob/main/train_dreambooth.py"
click node_lora_train "https://github.com/vinairesearch/anti-dreambooth/blob/main/train_dreambooth_lora.py"
click node_inference "https://github.com/vinairesearch/anti-dreambooth/blob/main/infer.py"
click node_face_eval "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/DeepFace.py"
click node_face_api "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/api/routes.py"
click node_face_service "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/api/service.py"
click node_face_prep "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/commons/functions.py"
click node_face_detectors "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/detectors/FaceDetector.py"
click node_face_models "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/basemodels/Facenet.py"
click node_deepface_attributes "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/extendedmodels/Emotion.py"
click node_face_distance "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/commons/distance.py"
click node_index_embeddings "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/compute_idx_emb.py"
click node_identity_scores "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/ism_fdfr.py"
click node_quality_eval "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/face_image_quality.py"
click node_mtcnn "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/insightface/src/mtcnn_detector.py"
click node_face_alignment "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/insightface/src/face_preprocess.py"
click node_quality_metrics "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/brisques.py"
click node_retinaface "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/RetinaFace.py"
click node_retina_model "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/model/retinaface_model.py"
click node_retina_post "https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/commons/postprocess.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_aspl,node_aspl_lora,node_ensemble_aspl,node_fsmg,node_ensemble_fsmg,node_protected_images,node_user toneBlue
class node_dreambooth_train,node_lora_train,node_model,node_inference,node_generated_images toneAmber
class node_face_eval,node_face_api,node_face_service,node_face_prep,node_face_detectors,node_face_models,node_deepface_attributes,node_face_distance,node_index_embeddings,node_identity_scores toneMint
class node_quality_eval,node_mtcnn,node_face_alignment,node_quality_metrics,node_retinaface,node_retina_model,node_retina_post toneRose
```

## Components

### Image defense

- [ASPL attack](https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/aspl.py): `attacks/aspl.py`
- [ASPL LoRA](https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/aspl_lora.py): `attacks/aspl_lora.py`
- [Ensemble ASPL](https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/ensemble_aspl.py): `attacks/ensemble_aspl.py`
- [FSMG attack](https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/fsmg.py): `attacks/fsmg.py`
- [Ensemble FSMG](https://github.com/vinairesearch/anti-dreambooth/blob/main/attacks/ensemble_fsmg.py): `attacks/ensemble_fsmg.py`
- **Perturbed images**

### DreamBooth generation

- [DreamBooth training](https://github.com/vinairesearch/anti-dreambooth/blob/main/train_dreambooth.py): `train_dreambooth.py`
- [LoRA training](https://github.com/vinairesearch/anti-dreambooth/blob/main/train_dreambooth_lora.py): `train_dreambooth_lora.py`
- **Trained model**
- [Image inference](https://github.com/vinairesearch/anti-dreambooth/blob/main/infer.py): `infer.py`
- **Generated images**

### Face identity analysis

- [Face evaluation](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/DeepFace.py): `evaluations/deepface/deepface/DeepFace.py`
- [Face API routes](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/api/routes.py): `evaluations/deepface/api/routes.py`
- [Face API service](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/api/service.py): `evaluations/deepface/api/service.py`
- [Face preprocessing](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/commons/functions.py): `evaluations/deepface/deepface/commons/functions.py`
- [Face detectors](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/detectors/FaceDetector.py): `evaluations/deepface/deepface/detectors/FaceDetector.py`
- [Embedding backbones](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/basemodels/Facenet.py): `evaluations/deepface/deepface/basemodels/Facenet.py`
- [Attribute models](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/extendedmodels/Emotion.py): `evaluations/deepface/deepface/extendedmodels/Emotion.py`
- [Distance metrics](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/deepface/deepface/commons/distance.py): `evaluations/deepface/deepface/commons/distance.py`
- [Index embeddings](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/compute_idx_emb.py): `evaluations/compute_idx_emb.py`
- [Identity scores](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/ism_fdfr.py): `evaluations/ism_fdfr.py`

### Image quality analysis

- [SER-FIQ scoring](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/face_image_quality.py): `evaluations/FaceImageQuality/face_image_quality.py`
- [MTCNN detection](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/insightface/src/mtcnn_detector.py): `evaluations/FaceImageQuality/insightface/src/mtcnn_detector.py`
- [Face alignment](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/FaceImageQuality/insightface/src/face_preprocess.py): `evaluations/FaceImageQuality/insightface/src/face_preprocess.py`
- [BRISQUE scoring](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/brisques.py): `evaluations/brisques.py`
- [RetinaFace detection](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/RetinaFace.py): `evaluations/retinaface/retinaface/RetinaFace.py`
- [RetinaFace model](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/model/retinaface_model.py): `evaluations/retinaface/retinaface/model/retinaface_model.py`
- [RetinaFace postprocess](https://github.com/vinairesearch/anti-dreambooth/blob/main/evaluations/retinaface/retinaface/commons/postprocess.py): `evaluations/retinaface/retinaface/commons/postprocess.py`

### Other components

- **User**

## Connections

- User → ASPL attack: selects defense
- User → ASPL LoRA: selects defense
- User → Ensemble ASPL: selects defense
- User → FSMG attack: selects defense
- User → Ensemble FSMG: selects defense
- ASPL attack → Perturbed images: perturbs images
- ASPL LoRA → Perturbed images: perturbs images
- Ensemble ASPL → Perturbed images: perturbs images
- FSMG attack → Perturbed images: perturbs images
- Ensemble FSMG → Perturbed images: perturbs images
- User → DreamBooth training: provides images
- User → LoRA training: provides images
- Perturbed images → DreamBooth training: trains on
- Perturbed images → LoRA training: trains on
- DreamBooth training → Trained model: trains
- LoRA training → Trained model: trains
- User → Image inference: requests generation
- Trained model → Image inference: loads model
- Image inference → Generated images: generates
- Face API routes → Face API service: routes requests (evidence: `evaluations/deepface/api/routes.py`)
- Face API service → Face evaluation: calls analysis (evidence: `evaluations/deepface/api/service.py`)
- Face evaluation → Face preprocessing: extracts faces (evidence: `evaluations/deepface/deepface/DeepFace.py`)
- Face preprocessing → Face detectors: dispatches detection (evidence: `evaluations/deepface/deepface/commons/functions.py`)
- Face evaluation → Embedding backbones: selects backbones (evidence: `evaluations/deepface/deepface/DeepFace.py`)
- Face evaluation → Attribute models: loads attributes (evidence: `evaluations/deepface/deepface/DeepFace.py`)
- Face evaluation → Distance metrics: uses metrics (evidence: `evaluations/deepface/deepface/DeepFace.py`)
- Index embeddings → Face evaluation: extracts embeddings (evidence: `evaluations/compute_idx_emb.py`)
- Identity scores → Face evaluation: extracts embeddings (evidence: `evaluations/ism_fdfr.py`)
- Identity scores → Index embeddings: loads reference embedding (evidence: `evaluations/ism_fdfr.py`)
- SER-FIQ scoring → MTCNN detection: detects faces (evidence: `evaluations/FaceImageQuality/face_image_quality.py`)
- SER-FIQ scoring → Face alignment: aligns faces (evidence: `evaluations/FaceImageQuality/face_image_quality.py`)
- RetinaFace detection → RetinaFace model: builds model (evidence: `evaluations/retinaface/retinaface/RetinaFace.py`)
- RetinaFace detection → RetinaFace postprocess: processes detections (evidence: `evaluations/retinaface/retinaface/RetinaFace.py`)
- User → SER-FIQ scoring: evaluates images
- User → BRISQUE scoring: evaluates images
- Generated images → Identity scores: measures identity
- Generated images → SER-FIQ scoring: measures quality
