CodeFormer icon

CodeFormer

Source Available
S-Lab, Nanyang Technological University

Evaluate CodeFormer for a permitted portrait restoration: compare fidelity settings, inspect face changes and recomposition, and check the non-commercial S-Lab license.

Image Upscale

At a glance

Input
A permitted face image, either already cropped and aligned or passed through the official whole-image detection and alignment workflow. Keep the unchanged source.
Output
A restored face crop and, in the whole-image path, a recomposed image. Generated facial details need source comparison; a saved file alone does not prove inference succeeded.
Access
Official repository code and its restoration checkpoint reference are public. S-Lab License 1.0 limits the stated grant to non-commercial purposes and directs commercial users to contact contributors. Hosted options have separate terms.
Who it fits
Photo editors and developers evaluating a permitted non-commercial display copy of a degraded portrait, with time to inspect inferred facial changes.
When to choose something else
Do not choose this workflow to establish an unknown identity or recover factual evidentiary detail. Also stop when every restoration changes features important to the intended display.
Cost and access conditions
Measure setup, detection, per-face restoration, optional upsampling, saving and manual review. No minimum VRAM, universal timing, hosted price or production capacity was tested here.

Key Highlights

A visible fidelity control

The documented weight spans 0 to 1; the CLI defaults to 0.5. Compare fixed inputs and inspect source-supported facial features instead of assuming one setting is universally best.

Separate face and full-image inspection

Aligned-face and whole-image paths have different preparation and output handling. Face selection and recomposition need checking alongside the restored crop.

Non-commercial project terms

The official project identifies S-Lab License 1.0. Public code and an official checkpoint reference do not grant blanket commercial permission or establish a hosted provider’s terms.

About

On this page

CodeFormer restores degraded face images using a learned visual prior and a Transformer. It can produce a more legible portrait, but newly generated facial detail is not evidence of what was present in the original scene. Evaluate it for a permitted display copy when you can inspect changes and preserve the source. The official project uses S-Lab License 1.0, which permits specified non-commercial uses and directs commercial users to contact the contributors.

This is a source-based evaluation of the official restoration implementation and research, not a report of image tests. No model inference, timing comparison or hosted-service submission was performed for this page. The family-photo exercise below is a proposed evaluation with unfilled results.

Decide what the restored portrait needs to preserve

The research frames blind face restoration as an ambiguous reconstruction problem. CodeFormer uses a learned discrete codebook as a visual prior, with a Transformer predicting code sequences. This helps explain both its intended use and its limit: a plausible face can contain inferred features that the damaged input does not establish. The paper is by Shangchen Zhou, Kelvin C. K. Chan, Chongyi Li and Chen Change Loy, affiliated with S-Lab at Nanyang Technological University. CodeFormer research paper.

Consider a scanned family portrait with compression artifacts, soft eyes and a scratch crossing one cheek. The reader's job is to make a display derivative that remains acceptable to the people represented. Before changing the image, identify what is actually visible: head angle, mouth shape, expression, distinctive marks and the relationship between the face and hair. Mark uncertain details as uncertain. A crisp eyelid or tooth added later does not resolve that uncertainty.

Keep the scan as the archival source and give the edited image a separate filename. Decide whether a slightly soft but recognisable face serves the purpose better than a sharper face with changed expression. This is an editorial acceptance decision, not a score produced by the model. Someone familiar with the person may help notice changes, but agreement with a familiar appearance still does not make generated detail a historical record.

Do not use this workflow to establish an unknown person's identity, reconstruct evidentiary detail or certify that a face is authentic. When those facts are the task, improving visual plausibility is not an adequate success criterion. A better scan, another permitted reference or retaining the damaged source may be the appropriate outcome.

Separate a face crop from the whole-image workflow

The official restoration script has two relevant entry paths. With --has_aligned, it treats the input as an aligned face and resizes it to 512 × 512. Without that flag, it detects faces, aligns face crops, restores them and can paste them back into the image. Its default detector is retinaface_resnet50; --only_center_face changes face selection. The script and its arguments, rather than a wrapper's product description, define this reviewed scope. Official inference implementation.

Choose the entry path from the material you actually have. An ordinary portrait is not necessarily an aligned face crop. In a family group, selecting only the centre face can exclude someone important. Inspect the selected crops before deciding that the restoration model missed a person or changed their face. If the wrong face reaches the restoration stage, adjusting the fidelity weight cannot correct that selection.

Whole-image quality includes recomposition. An acceptable isolated face may look pasted on when its sharpness, colour or boundary differs from the surrounding photograph. Review the returned face both at the crop's working scale and inside the full image at the intended display size. A tightly cropped comparison can conceal a seam near the hairline or an unnatural transition to the neck.

Optional Real-ESRGAN processing is a separate upsampling component in the official workflow. Background upsampling and face upsampling are separate switches; they are not prerequisites for every restoration. Begin without adding these stages so you can attribute a change to the relevant operation. The repository's aligned-face and whole-image examples have different purposes, so their outputs should not be treated as interchangeable evaluation conditions. Repository usage guidance.

Compare fidelity settings against the same source

The documented fidelity weight runs from 0 to 1. The repository describes smaller values as favouring visual quality and larger values as favouring fidelity. This is a control to investigate on your input, not a universal ordering of better and worse portraits. The CLI defaults to 0.5, which is a starting configuration rather than a recommendation for every photograph.

Hold the input, face-selection mode and other processing settings fixed while comparing weights. Use separate output folders and record the value with each image. Avoid selecting a result solely because its eyes look sharper: compare the same eyes, mouth and characteristic features with the original. A setting that works for one face in a group may be unacceptable for another.

Setting the weight to 1 does not promise an unchanged copy of the input. The architecture still performs learned restoration; its fusion path uses the weight to control features. Preserve the original independently instead of relying on one endpoint of the slider as an archival safeguard. CodeFormer architecture.

If every setting changes an important feature, reject those derivatives. Repeatedly adjusting a slider cannot demonstrate that a missing feature has been recovered. Record the rejection reason so that a later upsampling or retouching stage does not quietly reintroduce the same unacceptable face.

Check the actual license and access path

The official repository's S-Lab License 1.0 grants use and redistribution for non-commercial purposes subject to its conditions. These include retaining notices and restrictions on using contributor names for endorsement. It directs anyone needing commercial use or redistribution to contact the contributors. The reviewed project must therefore not be presented as an Apache 2.0 resource or as carrying a blanket commercial-use grant. Official S-Lab license.

Publicly readable code, a downloadable checkpoint and a paid hosted interface are different forms of access. Paying a provider does not itself establish the rights needed for your use of the underlying model, and a public demo is not evidence of an unrestricted license. For commercial work, establish the applicable permission and service terms before making the model part of a customer commitment. This page reports the project terms; it does not grant permission for a particular deployment.

The official downloader identifies a restoration checkpoint named codeformer.pth under the project's v0.1.0 release. That reference supports the existence of an official acquisition path; it is not a claim that this review downloaded, inspected or ran the binary. Keep the source revision, checkpoint origin and any locally recorded checksum with an evaluation record. A similarly named mirror should not silently replace the intended file. Official checkpoint downloader.

The README links author-maintained hosted options, but their capacity, prices, privacy practices and continuing operation were not tested here. For the family-photo exercise, choose a processing route that permits the intended handling of the photograph. Project availability does not resolve rights in the input image, permission to publish a person's portrait or the terms of optional dependencies. If any necessary permission is unclear, resolve it before submitting or redistributing material.

Run a bounded family-photo evaluation

Prepare a copy of a permitted scan and one less degraded portrait as a control. State the intended output, such as a private family display copy, and choose the features that must remain recognisable. Keep the original dimensions and record any cropping or resampling performed before inference. The control helps distinguish a problem specific to severe damage from a problem introduced by the chosen processing path; it is not a measured baseline until you run it.

Use the pinned official repository instructions to prepare an isolated environment, then record the versions actually installed and the device selected. The repository's installation recipe is not a compatibility certification for every current Python, PyTorch or operating-system combination. No installation was performed for this article. Resolve setup errors before comparing images, and keep the exact command and full log with each attempted run.

These are unexecuted comparison commands using flags present in the reviewed script. They assume the documented environment and required model files are already prepared. The paths are examples that you must replace with your permitted input and separate output locations. All three use the same ordinary-image workflow and leave the optional Real-ESRGAN background and face enhancement switches disabled. This does not disable the CLI's separate default --upscale 2 output scale.

python inference_codeformer.py -i inputs/family-photo.png -o results/family-w0 -w 0
python inference_codeformer.py -i inputs/family-photo.png -o results/family-w05 -w 0.5
python inference_codeformer.py -i inputs/family-photo.png -o results/family-w1 -w 1

Inspect face selection and alignment first, then compare each restored crop with the source, and finally inspect the recomposed image. Keep rejected outputs as well as a preferred derivative. If you add background or face upsampling, make it a separate recorded comparison after choosing an acceptable restoration. Otherwise, a visible improvement may come from another stage, and its contribution will be difficult to identify.

Accept a derivative with a face-specific worksheet

The following worksheet is an original proposed decision aid for this family-photo scenario. It contains no test results or quality ratings. Fill it with observations and saved artifacts before describing a run as successful.

StageDecision to makeEvidence to keep
Source evidenceWhich facial details are visible, and which are too damaged to establish?The unchanged scan with visible features and uncertainties noted.
Selection and alignmentDid the intended face enter restoration with an appropriate crop?The selected face crop alongside its location in the complete photograph.
Inferred facial changesDid expression or a recognisable feature change beyond the accepted display purpose?Comparable source and restored crops, setting values and a written acceptance or rejection reason.
RecompositionDoes the accepted face sit naturally within the photograph at the intended display size?The full output, with hairline, jaw, neck and surrounding texture inspected.
DeliveryCan the recipient distinguish the edited derivative from the archival source?Separate filenames, the preserved original and a note describing restoration.

Treat an attractive face that changes an important feature as a failed candidate for this task. Conversely, a conservative result may be useful even when some blur remains. Set the tolerance in terms of the intended photograph and recipient, not a generic sharpness target. The worksheet should make that choice explainable to someone who did not operate the model.

Set a correction budget before trying a larger collection. Count the time spent inspecting faces, rejecting outputs and repairing boundaries as part of the job. If a few photos require careful manual work, that may still be acceptable for a private album. If almost every face needs reconstruction, a batch workflow may remove less work than expected. Leave these observations blank until measured.

Diagnose the first artifact that is wrong

The reviewed script catches an exception during per-face restoration and substitutes the input crop for that face while reporting the failure. A saved image is therefore not sufficient evidence that model inference succeeded. Check the log and corresponding crop before counting an output as a restored face. This is especially relevant when a batch appears to finish but some faces are unchanged.

ObservationFirst evidence to inspectControlled next action
A person is absent from the restored facesFace-selection flags and detected crops.Verify the intended face was selected before changing restoration settings.
A face is unchanged despite an output fileThe inference log and source/restored crop pair.Resolve any reported failure, then rerun that input and confirm the log outcome.
Expression or distinctive features changeSource-supported details at the same crop and scale.Compare one fidelity setting at a time; reject all candidates if necessary.
A face looks pasted into the photographFull-image boundaries and optional upsampling settings.Compare recomposition with the isolated accepted crop before adding enhancement.
Processing exhausts resourcesInput dimensions, face count, optional stages and device log.Reduce the trial to a documented smaller workload and measure again.

These are diagnostic hypotheses and inspection steps, not measured failure rates. Do not label every unchanged face an exception or every boundary problem an upsampler fault. Use the saved artifacts to identify the earliest relevant difference. That keeps a subsequent fix attached to an observed problem rather than to a general impression of image quality.

Measure resources for the complete job

The reviewed device helper can select MPS, CUDA or CPU under its implemented availability and version checks. That code path is not proof of successful execution on your machine. The optional Real-ESRGAN setup also warns about slow CPU processing. There is no tested minimum VRAM, universal per-face time or throughput promise in this evaluation. Official device-selection helper.

Measure initial downloads and startup separately from repeat inference. Record the full image dimensions, face count, selected detector, fidelity weight, optional enhancement stages and actual hardware. Include saving and manual inspection when estimating how long a usable photograph takes. A timing for one aligned face does not describe processing a large group photograph with background upsampling.

Video needs its own resource plan. In the reviewed script, the video path collects input frames and later output frames in memory. Do not describe it as a bounded streaming workflow or extrapolate a short clip to an unrestricted recording. The existence of a video input path also does not establish stable facial appearance across frames. If video is required, begin with a short permitted clip and inspect adjacent frames and memory use explicitly.

Choose the next restoration step from the evidence

For the family portrait, the immediate decision is whether an acceptable display derivative exists with tolerable manual correction. If it does, preserve the exact settings, original and edited file together. If the changes remain unacceptable, choose a clearer scan, careful manual retouching or a limited correction that leaves uncertain facial detail unresolved. A rejected model output is useful evidence for that choice.

A face-restoration model and a general upscaler address different parts of the photograph. Select another method according to the observed need, such as a scratch outside the face or a recomposition problem, rather than assuming a different model name will solve every defect. This review does not establish a CodeFormer-versus-GFPGAN winner or reproduce the paper's benchmarks.

Use the model directory to explore other model categories once the missing capability is clear. Before expanding to a collection or service, resolve the applicable permissions and establish the actual workload and acceptance results. Neither sharper detail, successful file creation nor a public repository alone completes that evaluation.

Use Cases

1

Prepare a family portrait for private display

Use a permitted scan, identify features to preserve and compare a small set of recorded settings. Accept only an edited copy whose changes and boundaries suit the display purpose.

2

Evaluate the official restoration workflow

In a permitted non-commercial experiment, keep source, detected crops, restored faces, final images and logs to locate selection, inference or recomposition failures before expanding a batch.

Pros & Cons

Pros

  • The official implementation exposes a documented fidelity weight for controlled comparisons.
  • Separate face crops and full-image outputs allow selection and recomposition to be inspected.
  • Public source makes the inference fallback and optional enhancement stages inspectable.

Cons

  • Plausible restored facial detail can change identity-bearing features and cannot establish missing facts.
  • The official project’s non-commercial license is not a blanket permission for commercial services.
  • Per-face inference failures can still produce saved outputs; video buffering and optional enhancement require workload-specific resource checks.

Technical Details

Architecture

Transformer predicting discrete codes from a learned codebook for face restoration

License

S-Lab License 1.0

The pinned official CodeFormer repository identifies S-Lab License 1.0 and applies it to the project. It permits specified non-commercial source/binary use and redistribution subject to conditions, and directs commercial users to contact contributors. This is not Apache 2.0 or a blanket commercial-use grant. The official restoration checkpoint reference belongs to the reviewed project; the binary was not downloaded or independently audited. Dependencies, wrappers, hosted services, input rights and output use require their own checks. License source

Related Models

FidelityFx Super Resolution icon

FidelityFx Super Resolution

AMD|N/A

FidelityFX Super Resolution (FSR) is AMD's open-source spatial upscaling technology designed to boost performance in real-time rendering applications, particularly video games. Unlike NVIDIA's DLSS which requires dedicated Tensor Cores, FSR is hardware-agnostic and runs on AMD, NVIDIA, and Intel GPUs including integrated graphics. The technology has evolved through multiple generations: FSR 1.0 used Lanczos-based spatial upscaling on single frames, FSR 2.0 introduced temporal upscaling leveraging motion vectors and previous frame data for near-native quality, and FSR 3.0 added optical flow-based frame generation to dramatically increase perceived frame rates. Quality modes range from Ultra Quality to Ultra Performance, letting users balance visual fidelity against performance gains of up to 2x or more. FSR supports DirectX 11, DirectX 12, and Vulkan APIs and is deployed across PC, Xbox, PlayStation, and portable devices like Steam Deck where it enables playable frame rates within limited GPU power budgets. Hundreds of major titles including Cyberpunk 2077, Starfield, and Hogwarts Legacy feature FSR integration, with engine-level support in Unreal Engine and Unity simplifying adoption. Released under the MIT license through AMD's GPUOpen platform, FSR encourages transparent collaboration and modification by developers and researchers. Its platform independence and open-source nature have made it one of the most widely adopted upscaling solutions in the gaming industry, shaping the future of real-time image quality enhancement.

Open weights
Real-ESRGAN icon

Real-ESRGAN

Tencent ARC|N/A

Real-ESRGAN is an open-source image upscaling and restoration model developed by Xintao Wang and collaborators at Tencent ARC Lab that enhances low-resolution, degraded, or compressed images to high-resolution outputs with remarkable detail recovery. Released in 2021 under the BSD license, Real-ESRGAN builds on the original ESRGAN architecture by introducing a high-order degradation modeling approach that simulates the complex, unpredictable quality loss found in real-world images, including compression artifacts, noise, blur, and downsampling. The model uses a U-Net architecture with Residual-in-Residual Dense Blocks as its generator network, trained with a combination of perceptual loss, GAN loss, and pixel loss to produce sharp, natural-looking upscaled results. Real-ESRGAN supports upscaling factors of 2x, 4x, and higher, and includes specialized model variants for anime and illustration content alongside the general-purpose photographic model. The model handles real-world degradations far better than its predecessor ESRGAN, which was trained only on synthetic degradation patterns. Real-ESRGAN has become one of the most widely deployed AI upscaling solutions, integrated into numerous applications including desktop tools, web services, mobile apps, and professional image editing workflows. The model runs efficiently on both CPU and GPU, with the lighter RealESRGAN-x4plus-anime variant optimized for consumer hardware. As a fully open-source project available on GitHub with pre-trained weights, it serves as the backbone for popular tools like Upscayl and various ComfyUI nodes. Real-ESRGAN is essential for photographers, content creators, game developers, and anyone who needs to enhance image resolution while preserving natural appearance and adding realistic detail.

Open weights
StableSR icon

StableSR

Jianyi Wang|N/A

StableSR is an innovative super-resolution model developed by Jianyi Wang and collaborators that leverages the generative prior of a pre-trained Stable Diffusion model for high-quality image upscaling with realistic detail synthesis. Released in 2023 under the Apache 2.0 license, StableSR represents one of the first successful applications of diffusion-based generative models to the image super-resolution task. The model introduces a time-aware encoder that injects information from the low-resolution input image into the Stable Diffusion denoising process at each timestep, along with a controllable feature wrapping module that balances between fidelity to the original image and the richness of generated details. This architecture enables StableSR to produce upscaled images with remarkably realistic textures and fine details that go beyond what traditional regression-based super-resolution methods can achieve. The controllable feature wrapping allows users to adjust the strength of generative enhancement, providing a spectrum from conservative restoration that closely follows the input to aggressive enhancement that adds more synthesized detail. StableSR handles diverse image types including photographs, artwork, screenshots, and text-containing images, with particular strength in restoring natural textures like skin, hair, fabric, and foliage. The model is fully open source with code and pre-trained weights available on GitHub and is compatible with existing Stable Diffusion infrastructure. StableSR is valuable for photographers restoring low-resolution images, digital artists upscaling reference material, and content creators who need high-resolution outputs from limited source imagery. Its diffusion-based approach has influenced subsequent research in generative super-resolution methods.

Open weights
SUPIR icon

SUPIR

Fanghua Yu et al. (SUPIR author team)

Evaluate SUPIR restoration with controlled Q/F and caption comparisons, inspect invented detail, and clarify checkpoint permissions before a trial.

Source Available

Quick Info

ParametersN/A
Typetransformer
LicenseS-Lab License 1.0
Architecture

Transformer predicting discrete codes from a learned codebook for face restoration

CreatorS-Lab, Nanyang Technological University

Links

Tags

CodeFormer
Visit Website