CodeFormer
What is CodeFormer?
CodeFormer is an AI tool that repairs and sharpens faces in blurry or low-quality images and videos, using a library of learned high-quality facial details to reconstruct what the face should look like.
At a glance
- Type of model
- Face restoration and enhancement model using discrete codebook and transformer architecture
- Developed by
- S-Lab, Nanyang Technological University
- Key capability
- High-quality face restoration from degraded inputs with controllable fidelity-to-original balance
- How it fits in AI workflow
- Used as a post-processing step to enhance facial quality in AI-generated images, upscaled video, or archival footage restoration
Ready to create?
Direct scenes, design characters, and ship full films
All-in-one AI creative platform with simple, transparent pricing, no speed throttles, and an infinite Canvas for max creativity.
How it compares
Both are AI face restoration models that improve degraded face quality, but CodeFormer uses a codebook-based approach that generally produces better results on severely degraded inputs and offers a controllable fidelity parameter. GFPGAN was an earlier model that remains widely used and is faster, but CodeFormer is generally considered more capable for challenging restoration tasks.
Pro tip
When using CodeFormer on AI-generated faces, start with a fidelity weight around 0.5 and adjust based on whether identity preservation or output quality matters more for your use case: lower values give cleaner results but may drift from the original face, which can matter for character consistency across a production.
Types and variations
- CodeFormer is primarily released as a single model, though it can be run with different fidelity weight settings (typically expressed as a value between 0 and 1) that alter the balance between output quality and identity preservation.
- It is available through the official GitHub repository, integrated into AUTOMATIC1111 Stable Diffusion Web UI as a face restoration option, and used within various video enhancement and upscaling tools.
Ready to make your first scene in Morphic?
Try MorphicCommon use cases
- CodeFormer is used for restoring faces in old or low-quality photographs, enhancing facial detail in AI-generated images where face generation has produced blurry or artefact-laden results, improving face quality in upscaled video footage, and as part of video restoration pipelines for archival or historical media.
- It is also used in AI avatar and portrait enhancement workflows.
Ready to create?
Direct scenes, design characters, and ship full films
All-in-one AI creative platform with simple, transparent pricing, no speed throttles, and an infinite Canvas for max creativity.
FAQs
CodeFormer restores and enhances faces in degraded images and video by using a learned codebook of high-quality face components to reconstruct facial details, sharpness, and texture from blurry or low-resolution inputs.
Unlike simple upscaling, which enlarges pixels without adding real detail, CodeFormer hallucinates plausible high-quality facial details by referencing a learned library of real face components, resulting in much sharper and more realistic facial reconstruction.
The fidelity parameter, typically set between 0 and 1, controls how closely CodeFormer sticks to the original input face. Lower values prioritise output quality and sharpness, potentially altering identity slightly; higher values stay closer to the original appearance.
Yes, CodeFormer can be applied frame-by-frame to video footage to restore or enhance faces in video. It is used in video restoration pipelines, though processing every frame can be time-consuming without GPU acceleration.
CodeFormer is open-source and freely available through its GitHub repository. It is also integrated into several free and commercial AI image and video tools, including the AUTOMATIC1111 Stable Diffusion Web UI.
Use CodeFormer when you need higher quality results on severely degraded or very low-resolution faces, or when you want controllable fidelity. GFPGAN is faster and simpler, making it suitable when speed matters more or when inputs are only mildly degraded.