explaingit

sczhou/codeformer

Analysis updated 2026-06-24

17,960PythonAudience · researcherComplexity · 4/5Setup · hard

TLDR

AI tool that restores blurry or damaged faces in photos and videos, with extras for colorizing black-and-white pictures and filling in masked areas.

Mindmap

mindmap
  root((CodeFormer))
    What it does
      Face restoration
      Face colorization
      Face inpainting
      Video enhancement
    Tech stack
      Python
      PyTorch
      CUDA GPU
      Codebook transformer
    Use cases
      Old family photos
      AI art fixups
      Damaged footage
    Audience
      Researchers
      Photo hobbyists
      Restoration tools
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Restore blurry or damaged faces in old family photos.

USE CASE 2

Colorize black-and-white portraits.

USE CASE 3

Inpaint masked-out regions of a face to remove blemishes or scratches.

USE CASE 4

Enhance faces in old video footage frame by frame.

What is it built with?

PythonPyTorchCUDA

How does it compare?

sczhou/codeformertrekhleb/learn-pythonfastapi/sqlmodel
Stars17,96017,95517,928
LanguagePythonPythonPython
Setup difficultyhardeasyeasy
Complexity4/51/52/5
Audienceresearcherdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Needs Python + PyTorch + a CUDA-capable NVIDIA GPU. No-install option: use the Hugging Face or Replicate demos.

License is not stated in the explanation.

In plain English

CodeFormer is an AI-powered tool for restoring and enhancing faces in photos and videos. It was developed as a research project at Nanyang Technological University and presented at NeurIPS 2022, a top academic AI conference. The problem it solves: old or low-quality photos often have blurry, damaged, or degraded faces that are hard to view clearly. CodeFormer automatically sharpens and restores these faces using a technique called a "codebook lookup transformer", this means the AI has learned a library of high-quality face features and uses it to intelligently fill in missing or damaged details, rather than just blindly sharpening everything. Beyond basic face restoration, it also supports face colorization (turning black-and-white photos into color), face inpainting (filling in areas you mask out, like removing blemishes), and video enhancement. A key parameter called the "fidelity weight" lets you control a tradeoff between quality and faithfulness to the original, lower values give crisper, more enhanced results, higher values stay closer to what was originally there. You can try it through online demos on Hugging Face and Replicate without installing anything. For local use, it runs with PyTorch (a machine learning framework) and requires a CUDA-capable GPU (a type of graphics card used for AI processing). Input can be whole images or pre-cropped face photos, and the results are saved to an output folder. You'd use CodeFormer to restore family photos, fix AI-generated art with degraded faces, or enhance old video footage. It is written in Python.

Copy-paste prompts

Prompt 1
Walk me through running CodeFormer locally on a Linux box with an NVIDIA GPU, conda env, PyTorch version, and the inference command for a folder of photos.
Prompt 2
I want to restore an old black-and-white family photo. Give me the exact CodeFormer command line for colorization plus a sensible fidelity weight.
Prompt 3
Explain CodeFormer's 'fidelity weight' parameter and what values to try for (a) crisp Instagram look vs (b) staying faithful to the original face.
Prompt 4
Write a small Python script that loops over every .jpg in a folder, calls CodeFormer for face restoration, and saves results into ./restored/.
Prompt 5
I don't have a GPU. Compare using the CodeFormer Hugging Face Space vs the Replicate demo for restoring a single photo, which is faster and which lets me batch?

Frequently asked questions

What is codeformer?

AI tool that restores blurry or damaged faces in photos and videos, with extras for colorizing black-and-white pictures and filling in masked areas.

What language is codeformer written in?

Mainly Python. The stack also includes Python, PyTorch, CUDA.

What license does codeformer use?

License is not stated in the explanation.

How hard is codeformer to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is codeformer for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub sczhou on gitmyhub

Verify against the repo before relying on details.