A facial image synthesis database for rare genetic disease phenotypes, built on GestaltGAN and StyleGAN3
- Overview
- Key Features
- Model Architecture
- Synthetic Image Gallery
- Interactive Web Gallery
- Getting Started
- Acknowledgments
- Citation
- License
This repository provides a class-conditional StyleGAN3 model trained to generate synthetic facial images representing patients with rare genetic diseases. The generated images capture disease-specific facial phenotype patterns (facial gestalt) and serve multiple purposes in computational biology and medical AI research.
Primary Use Cases:
- Visualization of disease-specific facial patterns learned from real patient data
- Generation of synthetic training/evaluation data for rare disease facial recognition models
- Educational materials and clinical teaching resources
- Data augmentation for downstream phenotype analysis tasks
- Privacy-preserving research by providing synthetic alternatives to real patient images
ℹ️ Important Note: This repository focuses on synthetic face generation using StyleGAN3. It does not perform disease diagnosis. All generated images are fully synthetic and do not represent real patients.
🙏 Code origin: The code in this repository is based on GestaltGAN (Kirchhoff et al., European Journal of Human Genetics, 2025), which itself extends NVIDIA's official StyleGAN3 implementation (Karras et al., NeurIPS 2021). The model behind the released images was trained with this code with the GestaltGAN gestalt loss turned off. See Acknowledgments for details, and please cite both works (see Citation).
- ✨ Class-conditional generation across multiple rare genetic disease categories
- 🎯 Alias-free architecture (StyleGAN3) for improved geometric consistency
- 🖼️ High-quality 224×224 resolution synthetic faces compatible with standard computer vision pipelines
- 🎮 Controllable generation with latent space manipulation capabilities
- 🌐 Interactive web gallery for exploring generated samples by disease type, demographics, and other attributes
The generator architecture is StyleGAN3. The training code is GestaltGAN, which adds disorder-specific components on top of StyleGAN3. Our training run turned the GestaltGAN gestalt loss off (see Acknowledgments). Key characteristics:
- Alias-free generator ensuring better pose consistency and geometric transformations
- Conditional generation supporting 10+ disease classes (configurable)
- Training data: Preprocessed facial images from genetic disease patient databases
- Resolution: 224×224 pixels (can be adjusted)
We provide sample synthetic faces generated by our trained StyleGAN3 model across different disease categories:
Explore our complete synthetic image database through an interactive web interface:
🌐 Phenotype-Disease Synthetic Image Database
- Browse by disease type: Filter synthetic faces by specific genetic disease categories
- Demographic filtering: Search by age range, gender, and ethnicity
- Metadata annotations: View generation parameters and conditional attributes
- Download capability: Export images for research and educational use
- High-quality samples: Access almost hundreds of synthetic faces per disease class
⚠️ Disclaimer: All images in the gallery are fully synthetic and generated by StyleGAN3. They do not represent real patients and are intended solely for research and educational purposes. Please respect ethical guidelines when using these materials.
# Clone the repository
git clone https://github.com/WGLab/PDI-DB.git
cd PDI-DB
# Create a new conda environment
conda create -n PDI-DB python=3.8
# Activate environment
conda activate PDI-DB
# Install PyTorch with CUDA support
pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu118
# Install other dependencies
pip install click pillow scipy numpy requests tqdm ninja matplotlib imageio
pip install imgui glfw pyopengl imageio-ffmpeg pyspngBefore training, you need to prepare your facial phenotype images in the correct format.
Organize your raw images in the following structure:
raw_data/
├── disease_0/
│ ├── patient_001.jpg
│ ├── patient_002.jpg
│ └── ...
├── disease_1/
│ ├── patient_001.jpg
│ ├── patient_002.jpg
│ └── ...
└── disease_N/
├── patient_001.jpg
└── ...
📊 Note: Training Dataset Information
The synthetic images showcased in this repository were generated using a model trained on 2,357 facial images across 11 categories:
- Disease images (10 categories, 1,857 images): Cornelia de Lange Syndrome (447), Williams-Beuren Syndrome (273), Noonan Syndrome (217), Kabuki Syndrome (206), KBG Syndrome (179), Angelman Syndrome (160), Rubinstein-Taybi Syndrome (116), Smith-Magenis Syndrome (102), Nicolaides-Baraitser Syndrome (97), and 22q11.2 Deletion Syndrome (60). All disease images are sourced from the GestaltMatcher Database (GMDB).
- Healthy control images (500 images): Selected from the FFHQ dataset with age < 20 years.
You can also train the model on your own custom disease categories and sample sizes by following the data preprocessing steps below.
Manual Preprocessing:
- Face Alignment: Align all faces to a standard pose using landmark detection
- Resolution: Resize images to 224×224 pixels
- Format: Convert to PNG or JPG format
- Quality Control: Remove low-quality or ambiguous images
python dataset_tool.py \
--source=raw_data/ \
--dest=datasets/phenotype_disease_224x224.zip \
--resolution=224x224The final dataset should be a ZIP file containing:
phenotype_disease_224x224.zip
├── 00000/
│ ├── img00000000.png
│ ├── img00000001.png
│ └── ...
├── 00001/
│ └── ...
└── dataset.json # Metadata with class labels
Example dataset.json format:
{
"labels": [
["img00000000.png", 0],
["img00000001.png", 0],
["img00000002.png", 1]
]
}Where the second value in each pair is the disease class index (0, 1, 2, ..., N).
Train a class-conditional StyleGAN3 model on your phenotype dataset:
python train.py \
--outdir=./training-runs \
--data=./datasets/phenotype_disease_224x224.zip \
--cfg=stylegan3-t \
--gpus=8 \
--batch=32 \
--cond=True \
--gamma=2 \
--mirror=1 \
--kimg=5000| Parameter | Description | Recommended Value |
|---|---|---|
--outdir |
Output directory for training results | ./training-runs |
--data |
Path to your preprocessed dataset ZIP | Required |
--cfg |
Model configuration (stylegan3-t, stylegan3-r, stylegan2) |
stylegan3-t |
--gpus |
Number of GPUs to use | 1–8 |
--batch |
Total batch size across all GPUs | 32 |
--cond |
Enable class-conditional generation | True |
--gamma |
R1 regularization weight | 2–8 |
--mirror |
Enable horizontal flipping augmentation | 1 (enabled) |
--kimg |
Training duration in thousands of images | 5000 |
--snap |
Snapshot interval (in ticks) | 20 |
python train.py \
--outdir=./training-runs \
--data=./datasets/phenotype_disease_224x224.zip \
--cfg=stylegan3-t \
--gpus=8 \
--batch=32 \
--cond=True \
--gamma=2 \
--mirror=1 \
--kimg=5000 \
--snap=20Training outputs are saved in timestamped directories:
training-runs/
└── 00000-stylegan3-t-phenotype_disease_224x224-gpus8-batch32-gamma2/
├── network-snapshot-000000.pkl # Initial model
├── network-snapshot-000100.pkl # Checkpoint at 100k images
├── fakes000000.png # Sample images at start
├── fakes000100.png # Sample images at 100k
├── training_stats.jsonl # Training metrics
└── metric-fid50k_full.jsonl # FID scores (if enabled)
Key files to monitor:
fakes*.png: Visual quality of generated imagestraining_stats.jsonl: Loss values and training metricsnetwork-snapshot-*.pkl: Model checkpoints
Once training is complete, use the trained model to generate synthetic phenotype images.
python gen_images.py \
--network=./training-runs/00000-stylegan3-t-.../network-snapshot-005000.pkl \
--outdir=./generated_images \
--samples=100 \
--class=0 \
--trunc=1.0| Parameter | Description | Example |
|---|---|---|
--network |
Path to trained model .pkl file |
network-snapshot-005000.pkl |
--outdir |
Output directory for generated images | ./generated_images |
--samples |
Number of images to generate | 100 |
--class |
Disease class index (0, 1, 2, ...) | 0 |
--trunc |
Truncation psi (0.5–1.0 for quality vs diversity) | 1.0 |
The --trunc parameter controls the trade-off between quality and diversity:
--trunc=0.5: Higher quality, less diversity (more typical faces)--trunc=0.7: Balanced quality and diversity--trunc=1.0: Maximum diversity, lower average quality
Examples:
# High quality, low diversity
python gen_images.py --network=model.pkl --outdir=out_quality --samples=100 --class=0 --trunc=0.5
# Balanced
python gen_images.py --network=model.pkl --outdir=out_balanced --samples=100 --class=0 --trunc=0.7
# High diversity
python gen_images.py --network=model.pkl --outdir=out_diverse --samples=100 --class=0 --trunc=1.0This repository is built on the work of two other groups, and we thank them for making their code public.
GestaltGAN. The code in this repository is based on the GestaltGAN codebase by Aron Kirchhoff and colleagues (github.com/kirchhoffaron/gestaltgan; Kirchhoff et al., European Journal of Human Genetics, 2025, doi:10.1038/s41431-025-01787-z). GestaltGAN trains StyleGAN3 on facial images of individuals with rare genetic disorders. The following files come from GestaltGAN unchanged or with small changes:
training/gestalt_loss.py: the gestalt loss, which uses GestaltMatcher models to give the generator disorder-specific feedback.training/dataset.py: class-balanced oversampling of the training images.training/loss.py: the StyleGAN2 loss extended with the gestalt loss.gen_images.py: image generation with--samplesand--latent_vectors.ganinversion.py,ganinversion/: GAN inversion utilities.
What we changed. The model behind the images in this repository and in the web gallery was trained without the gestalt loss. We made the loss optional in training/loss.py: it is only built when the GestaltMatcher model paths and encodings are given, and our training run did not give them. We also added a learning-rate scheduler and Weights & Biases logging to training/training_loop.py, and a small logging fix to dnnlib/util.py.
StyleGAN3. GestaltGAN, and therefore this repository, builds on NVIDIA's official StyleGAN3 implementation (github.com/NVlabs/stylegan3; Karras et al., NeurIPS 2021). All other code files come from StyleGAN3, and the generator and discriminator architectures are those of StyleGAN3. training/training_loops_original.py is an unmodified copy of the StyleGAN3 training loop, and training/training_loops_ddp.py is our variant of it with DistributedDataParallel.
Data. Disease images come from the GestaltMatcher Database (GMDB). Healthy control images come from the FFHQ dataset.
If you use this repository, please cite GestaltGAN and StyleGAN3:
@article{kirchhoff2025gestaltgan,
title = {{GestaltGAN}: synthetic photorealistic portraits of individuals with rare genetic disorders},
author = {Kirchhoff, Aron and Hustinx, Alexander and Javanmardi, Behnam and
Hsieh, Tzung-Chien and Brand, Fabian and Hellmann, Fabio and
Mertes, Silvan and Andr{\'e}, Elisabeth and Moosa, Shahida and
Schultz, Thomas and Solomon, Benjamin D. and Krawitz, Peter},
journal = {European Journal of Human Genetics},
year = {2025},
volume = {33},
number = {3},
pages = {377--382},
doi = {10.1038/s41431-025-01787-z}
}
@inproceedings{karras2021stylegan3,
title = {Alias-Free Generative Adversarial Networks},
author = {Karras, Tero and Aittala, Miika and Laine, Samuli and H{\"a}rk{\"o}nen, Erik and
Hellsten, Janne and Lehtinen, Jaakko and Aila, Timo},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
year = {2021}
}This repository contains code derived from NVIDIA's StyleGAN3 and is therefore distributed under the NVIDIA Source Code License for StyleGAN3 (see LICENSE). The license permits non-commercial use only (research or evaluation purposes).