CodeFormer
Codebook-based transformer that restores degraded faces in photos and video, non-commercial only.
About
Badly degraded faces are hard to restore because many plausible faces could explain the same damaged input. CodeFormer, a NeurIPS 2022 method from S-Lab at Nanyang Technological University, narrows that ambiguity by first learning a discrete codebook of high-quality facial parts, then using a transformer to predict which codebook entries best describe a degraded face. A fidelity weight between 0 and 1 trades crisp detail against faithfulness to the original. The repository provides PyTorch inference scripts for aligned 512 pixel face crops, whole photographs with optional Real-ESRGAN background upscaling, and video clips, plus separate checkpoints for colorizing faded monochrome faces and filling masked areas. Training code and configs are included. Setup needs a conda environment, the bundled BasicSR package, downloaded weights, and ideally a CUDA GPU. Its S-Lab license, version 1.0, permits non-commercial use only, and commercial deployment requires contacting the authors, who note that several CodeFormer-branded websites are unofficial. Good for anyone repairing old portraits or AI art.
Should you use CodeFormer?
Pick it when
You restore old family photos or severely degraded faces for personal, archival, or research use and want a fidelity weight to trade identity accuracy against cleaner, more detailed results.
Look elsewhere when
You need commercial use: the repository's S-Lab License 1.0 allows non-commercial use only, so GFPGAN (Apache-2.0) is the safer pick. The model restores faces only, so backgrounds need Real-ESRGAN alongside it.
Alternatives to CodeFormer
- GFPGAN
Apache-2.0 for commercial work and a clean install without custom CUDA extensions, though its V1.2 weights add a beautification effect.
- SUPIR
Restores the whole photo, not only faces, with text-guided SDXL detail, but needs around 12GB VRAM and also bars commercial use.
- Real-ESRGAN
Upscales whole images including backgrounds under BSD-3-Clause, but rebuilds faces only through its optional GFPGAN pass, with no fidelity weight.
- IOPaint (Lama Cleaner)
Bundles GFPGAN and RestoreFormer face restoration with inpainting in one browser UI, easier than running CodeFormer's scripts.
Reviews (0)
Leave a Review
No reviews yet. Be the first to review!
Details
- Category
- AI Image/Video Editing
- Price
- Free
- Platform
- Local/Desktop
- Difficulty
- Easy (2/5)
- License
- S-Lab License 1.0
- Minimum VRAM
- 4 GB
- Added
- Apr 3, 2026