ScriptsMay 2, 2026·3 min read

GFPGAN — AI Face Restoration with Generative Facial Prior

Open-source face restoration algorithm that leverages generative facial priors from a pretrained face GAN to recover realistic faces from degraded inputs.

Introduction

GFPGAN is a face restoration algorithm developed by Tencent ARC Lab that uses Generative Facial Prior embedded in a pretrained face GAN for blind face restoration. It handles real-world degradation including blur, noise, compression artifacts, and low resolution without requiring paired training data.

What GFPGAN Does

  • Restores faces from severely degraded images (old photos, low-resolution video frames)
  • Leverages rich facial geometry and texture priors from a pretrained StyleGAN2
  • Handles both aligned face crops and full images with face detection
  • Supports adjustable restoration strength for balancing fidelity and quality
  • Provides a real-world inference pipeline with background enhancement via Real-ESRGAN

Architecture Overview

GFPGAN uses a U-Net degradation removal module connected to a pretrained StyleGAN2 face generator through spatial feature transform (SFT) layers. Channel-split spatial feature transforms inject multi-resolution identity-preserving features into the generator, balancing realness from the GAN prior with fidelity to the input face. A local discriminator on facial components (eyes, mouth) ensures detailed texture recovery.

Self-Hosting & Configuration

  • Install via pip: pip install gfpgan or clone the repo and install from source
  • Download pretrained models (GFPGANv1.4 recommended) from GitHub releases
  • Requires PyTorch >= 1.7 and a CUDA-capable GPU for real-time processing
  • Adjust upscale factor with -s and model version with -v flags
  • Integrates with Real-ESRGAN for background enhancement in full images

Key Features

  • Blind face restoration without requiring degradation-type knowledge
  • Generative facial prior from StyleGAN2 produces realistic textures
  • Identity-preserving through spatial feature transforms
  • Works on both cropped faces and whole images with automatic face detection
  • Color correction and paste-back for natural-looking full-image output

Comparison with Similar Tools

  • Real-ESRGAN — general-purpose image super-resolution; GFPGAN focuses specifically on faces
  • CodeFormer — similar face restoration using codebook lookup; slightly different quality-fidelity tradeoff
  • DFDNet — dictionary-based face restoration with component dictionaries
  • VQFR — uses vector-quantized codebook for face restoration
  • PULSE — generates high-resolution faces via StyleGAN but less faithful to input

FAQ

Q: Does GFPGAN work on non-face images? A: No, it is specialized for face restoration. For general images, use Real-ESRGAN or similar super-resolution tools.

Q: What GPU memory is required? A: Approximately 4 GB VRAM for processing single faces at standard resolution. Full images with background enhancement need more.

Q: Can I use GFPGAN in a commercial product? A: The code is released under Apache 2.0 license, but check the pretrained model licenses separately.

Q: How does it handle multiple faces in one image? A: The pipeline uses face detection to locate and restore each face individually, then pastes them back into the enhanced background.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets