How tencentarc/gfpgan works
GFPGAN is a practical blind face-restoration package. Its main user workflow reads images, selects and loads a restoration model, detects and aligns faces, restores each crop, optionally enhances the background, then pastes faces back and saves results. The repository also provides a BasicSR-based training path and multiple model families, including RestoreFormer and bilinear variants. The source excerpts show inference and restoration-helper calls; training internals and several architecture implementations were not sampled, so their detailed runtime connections are omitted.
Main entry points: utils.py GFPGANer · inference_gfpgan.py Inference CLI · gfpgan_bilinear_arch.py Bilinear GFPGAN · train.py Training entry point
Components 15
Inference workflow
- Inference CLI
inference_gfpgan.py - GFPGANer
gfpgan/utils.py - Restoration outputs
inference_gfpgan.py
Face restoration
- Face detection and alignment
- Real-ESRGAN upsampler
Model architectures
- Clean GFPGAN
gfpgan/archs/gfpganv1_clean_arch.py - Original GFPGAN
gfpgan/archs/gfpganv1_arch.py - Bilinear GFPGAN
gfpgan/archs/gfpgan_bilinear_arch.py - RestoreFormer
gfpgan/archs/restoreformer_arch.py - Clean StyleGAN2
gfpgan/archs/stylegan2_clean_arch.py - Bilinear StyleGAN2
gfpgan/archs/stylegan2_bilinear_arch.py
Training
- Degradation dataset
gfpgan/data/ffhq_degradation_dataset.py - GFPGAN training model
gfpgan/models/gfpgan_model.py - Training entry point
gfpgan/train.py
Other components
- Image user
Connections 15
- Image user → Inference CLI: runs
README.md - Inference CLI → GFPGANer: calls
inference_gfpgan.py - GFPGANer → Face detection and alignment: detects and aligns
gfpgan/utils.py - GFPGANer → Clean GFPGAN: selects model
gfpgan/utils.py - GFPGANer → Original GFPGAN: selects model
gfpgan/utils.py - GFPGANer → Bilinear GFPGAN: selects model
gfpgan/utils.py - GFPGANer → RestoreFormer: selects model
gfpgan/utils.py - GFPGANer → Real-ESRGAN upsampler: upsamples background
gfpgan/utils.py - Clean GFPGAN → Clean StyleGAN2: uses generator
gfpgan/archs/gfpganv1_clean_arch.py - Bilinear GFPGAN → Original GFPGAN: reuses architecture
gfpgan/archs/gfpgan_bilinear_arch.py - Bilinear GFPGAN → Bilinear StyleGAN2: uses generator
gfpgan/archs/gfpgan_bilinear_arch.py - Inference CLI → Real-ESRGAN upsampler: configures optionally
inference_gfpgan.py - Inference CLI → Restoration outputs: writes images
inference_gfpgan.py - Training entry point → Degradation dataset: registers datasets
gfpgan/train.py - Training entry point → GFPGAN training model: registers models
gfpgan/train.py