Repolode
sczhou

sczhou/CodeFormer

A PyTorch-based blind face restoration model that repairs degraded, low-quality, or old face photos using a codebook lookup transformer.

Open-source alternative to:ReminiTopaz Photo AI

Stars
18,183
Forks
3,723
Open issues
283
Last commit
11 months ago

What is it?

CodeFormer is a face restoration model from NTU S-Lab, published at NeurIPS 2022. It takes degraded face images with unknown corruption, such as blur, noise, low resolution, or age-related damage, and produces cleaner, more detailed faces. It uses a learned codebook of high-quality facial features combined with a transformer to find the best matching features for each face.

The repository provides command-line inference for several tasks: restoring cropped and aligned 512x512 faces, enhancing whole images with optional Real-ESRGAN background upscaling, processing video files, colorizing black-and-white or faded photos, and inpainting masked regions. A fidelity weight parameter lets users trade off between output quality and similarity to the input. Training code and configuration files are also included.

Setup requires PyTorch 1.7.1 or later, CUDA 10.1 or later, and pretrained weights downloaded through a provided script. Face detection can use the bundled facelib detector or dlib.

Key features

  • 01Restores blurred, noisy, or low-resolution faces with a fidelity weight to balance quality and similarity.
  • 02Processes cropped and aligned faces, whole images, and video files.
  • 03Colorizes black-and-white or faded face photos.
  • 04Inpaints masked face regions.
  • 05Optionally upscales backgrounds and faces with Real-ESRGAN.
  • 06Includes training code and config files.

Use cases

  • Restoring old or damaged family photos.
  • Enhancing low-quality face footage in video clips.
  • Fixing distorted faces in AI-generated art.
  • Research comparisons of blind face restoration methods.

Topics

FAQ

What is CodeFormer?
A PyTorch-based blind face restoration model that repairs degraded, low-quality, or old face photos using a codebook lookup transformer. CodeFormer is a face restoration model from NTU S-Lab, published at NeurIPS 2022. It takes degraded face images with unknown corruption, such as blur, noise, low resolution, or age-related damage, and produces cleaner, more detailed faces. It uses a learned codebook of high-quality facial features combined with a transformer to find the best matching features for each face.
Is CodeFormer free to use? What license does it have?
CodeFormer is open source under the Other license. Check the license terms before using it in commercial products.
Is CodeFormer still maintained?
No commits for 6+ months. The last commit to CodeFormer was on Nov 18, 2025.
What can I use CodeFormer for?
Restoring old or damaged family photos. Enhancing low-quality face footage in video clips. Fixing distorted faces in AI-generated art. Research comparisons of blind face restoration methods.
Where can I get CodeFormer?
The source code and installation instructions are on GitHub: https://github.com/sczhou/CodeFormer

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects