AI Tools
中文

CodeFormer Hands-On: NeurIPS 2022 Face Restoration, Does It Actually Deliver?

CodeFormer is a NeurIPS 2022 blind face restoration algorithm that can recover blurry, low-resolution, and damaged old photos remarkably naturally. I ran it on real samples — here's how well it performs.

Face RestorationBlind Face RestorationNeurIPSPyTorchVQGANCodebook

广告

I dug up some old family photo albums. Most of the pictures were blurry, cracked, or had faces you could barely make out. I tried a few online restoration tools, but the results were either too plastic-looking or didn’t resemble the actual person. Then I found CodeFormer, a blind face restoration method from NeurIPS 2022 with nearly 18k stars on GitHub. After running it through my samples, it’s clearly the most natural face restoration approach I’ve tried.

What Problem Does It Actually Solve

Traditional face restoration falls into two camps: reference-based methods that need a high-quality photo of the same person as guidance, and blind restoration that works from just the degraded image alone. CodeFormer takes the harder second route, which is also far more practical — where are you going to find a reference photo for a decades-old snapshot?

Its core innovation is the Codebook Lookup Transformer. It first learns a discrete codebook of high-quality facial features, then during restoration it looks up the most suitable feature combinations from this codebook rather than generating pixels directly. This produces more stable results with fewer weird artifacts.

Setup and Running

Hardware requirements are modest — any CUDA-capable GPU will do. I ran it on an RTX 3060 with 12GB VRAM and had plenty of headroom.

# Clone the repo
git clone https://github.com/sczhou/CodeFormer.git
cd CodeFormer

# Create environment
conda create -n codeformer python=3.9
conda activate codeformer

# Install dependencies
pip install -r requirements.txt
python basicsr/setup.py develop

Download pretrained weights:

python scripts/download_pretrained_models.py CodeFormer

Then you’re ready to go:

# Restore a single image
python inference_codeformer.py -w 0.7 --input_path path/to/your/image.jpg --output_path result/

# Batch restore a folder
python inference_codeformer.py -w 0.7 --input_path path/to/folder/ --output_path result/

The -w parameter controls restoration strength, from 0 to 1. Higher values restore more aggressively but risk losing personal characteristics. I found 0.7 to be a solid sweet spot.

Real Restoration Results

I tested three types of samples:

Mildly blurry old photos — hair texture, eyebrow direction, and skin quality all came back nicely. The most impressive part was the eyes. Many restoration algorithms turn eyes into dead fish stares, but CodeFormer keeps the spark alive.

Heavily compressed JPEGs — images with obvious block artifacts got smoothed out while recovering plausible detail. It’s not just skin-smoothing; it genuinely “guesses” the original detail.

Partially damaged photos — scratches and missing corners. It works best paired with an inpainting tool first, then CodeFormer for face enhancement. The extra step is worth it for significantly better results.

What I Liked

Academic quality, industrial usability. Backed by a NeurIPS 2022 oral paper, not some random GitHub demo. Complete code, clear docs, pretrained models ready to use.

High naturalness. Unlike some tools that make everyone look like they had Korean plastic surgery, CodeFormer preserves original features and age. Old people still look old — not transformed into fresh-faced youths.

Controllable restoration strength. The -w parameter lets you dial in exactly how much restoration to apply, adjusting flexibly based on image quality.

Video support. Beyond single images, it can restore faces frame-by-frame in videos, which is valuable for digitizing old tape footage.

The Downsides

Faces only. Backgrounds, clothing, and scene restoration aren’t its strengths. If the entire old photo is degraded, restoring just the face can look jarring.

Limited on extreme low resolution. If the face in the original is only a dozen pixels across, nothing can save it. It excels at “poor quality but has information,” not “barely any information at all.”

Skin tones occasionally skew light. Under certain lighting conditions, restored skin can come out slightly brighter than reality, needing some post-processing.

Depends on face detection. If the face is at an extreme angle or heavily occluded, detection fails and no restoration happens.

Who Should Use It

If you have old photo restoration needs — family album digitization, historical archive repair, or vintage film material remastering — CodeFormer is in the top tier of open-source solutions. You don’t need to understand deep learning; install the environment, run the command, and get results.

But if you’re doing professional photography retouching with pixel-precise control requirements, commercial software like Topaz Gigapixel AI paired with manual adjustments is probably still more reliable.

Bottom Line

CodeFormer turned a top-tier conference paper into a genuinely usable tool, which is rarer than you’d think in academia. Its 18k stars reflect broad recognition of both quality and usability. For everyday users, it’s the best free option for restoring faces in old photos. For researchers, its implementation and pretrained models are an important benchmark in the face restoration field. Worth trying.

GitHub: https://github.com/sczhou/CodeFormer Paper: https://arxiv.org/abs/2206.11253


About the Author

Liudingyu is a full-stack developer and heavy GitHub user. With 900+ starred repos over the past 3 years, this site only covers tools I’ve actually used or deeply researched.

📧 Found a great tool to recommend? Email [email protected]

广告

Related Posts