explaingit

tencentarc/gfpgan

37,457PythonAudience · developerComplexity · 2/5StaleSetup · hard

TLDR

Python tool that restores blurry, damaged, or low-resolution face photos to sharp, detailed images using AI trained on realistic faces.

Mindmap

mindmap
  root((GFPGAN))
    What it does
      Restores blurry faces
      Fixes low resolution
      Removes compression damage
    How it works
      Uses StyleGAN2 model
      Detects and aligns faces
      Fills in realistic details
    Use cases
      Old scanned photos
      Surveillance footage
      Social media stills
    Tech stack
      Python PyTorch
      CUDA GPU optional
      Real-ESRGAN background
    Getting started
      Command line tool
      Pip package install
      Multiple model versions

Things people build with this

USE CASE 1

Restore old scanned family photos that are blurry or faded to make them sharp and clear.

USE CASE 2

Enhance low-resolution faces from surveillance video or social media screenshots for better detail.

USE CASE 3

Fix heavily compressed or degraded portrait photos to recover lost facial features and texture.

USE CASE 4

Batch process multiple damaged photos automatically from the command line.

Tech stack

PythonPyTorchCUDAStyleGAN2Real-ESRGAN

Getting it running

Difficulty · hard Time to first run · 1h+

Requires CUDA/GPU setup, PyTorch compilation, and large pre-trained model downloads.

License could not be detected automatically. Check the repository's LICENSE file before use.

In plain English

GFPGAN is a Python library developed by Tencent's Applied Research Center that restores damaged, blurry, or low-quality face photos to sharp, detailed images. The problem it tackles is "blind face restoration", meaning the tool has to improve a face image without knowing exactly what kind of damage was applied (compression, blurriness, noise, low resolution, or all of the above at once). The key concept behind how it works is using a pre-trained face GAN (Generative Adversarial Network), specifically StyleGAN2, a model that has already learned what realistic human faces look like, as a guide. Rather than guessing at missing details from scratch, GFPGAN draws on StyleGAN2's built-in knowledge of face structure to fill in realistic-looking eyes, skin texture, and hair. This approach is called a "generative facial prior." The tool detects and aligns faces in an image first, applies the restoration model, and can optionally enhance the non-face background using a companion library called Real-ESRGAN. Multiple model versions exist, with newer versions producing more natural results. You would use GFPGAN when you have old scanned photos of people that are blurry or degraded, or when you have low-resolution video stills from surveillance footage or social media that you want to sharpen. It is also useful for restoring compressed or heavily edited portrait photos. The tool runs from the command line as a Python script and requires Python 3.7 or higher with PyTorch installed. A GPU with CUDA is recommended for reasonable speed, though CPU-only mode works on Windows. The library is also available as a pip package.

Copy-paste prompts

Prompt 1
How do I use GFPGAN to restore a blurry face photo? Show me the command-line steps.
Prompt 2
I have 100 old scanned photos with damaged faces. How can I batch restore them all with GFPGAN?
Prompt 3
What's the difference between GFPGAN model versions, and which one should I use for old family photos?
Prompt 4
Can I use GFPGAN on my CPU, or do I need a GPU? What's the speed difference?
Prompt 5
How do I install GFPGAN as a Python package and call it from my own script?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.