Scope note: open-source selection and local setup only
Let us be clear about the boundary first. This article does not review any mobile app, nor does it benchmark cloud services. We do exactly one thing: walk through three open-source old-photo restoration models that each have tens of thousands of GitHub stars, ship downloadable weights for free, and run on your own machine, so you can decide which to install, how to install it, and whether you may use it commercially. Online mini-programs from Tencent, ByteDance, and Alipay are mentioned only in one line at the end as the "do not want to run locally" exit, and we will not expand on them. The reason is simple: the strength of open-source models is that your data never leaves your machine, the parameters are controllable, and you can batch-process a whole box of family photos, whereas online services usually require uploading the original, charge per image, and hide what they actually do. If you care about privacy or need to restore a crate of ancestry photos, local deployment is the real answer.
The three models and their repositories
All three repositories are given below in both link and plain form so you can copy directly.
CodeFormer
The sczhou/CodeFormer repository, plain address: https://github.com/sczhou/CodeFormer
At the time of our check, CodeFormer has roughly 18,202 stars on GitHub. Its license field returned by the GitHub API is NOASSERTION, meaning it was not normalized by the standard license classifier; the project README states the license as NTU S-Lab License 1.0, a non-commercial license, and the pretrained weights are, per the authors' statement, restricted to research and non-commercial use. Its core strength is blind face restoration: without you marking where the face is, the model uses a Codebook Lookup Transformer to naturally complete blurred, damaged, low-resolution faces. It shines on faces, especially severely degraded old photos where the features are barely visible, and the result looks like a person rather than an obvious face swap.
GFPGAN
The TencentARC/GFPGAN repository, plain address: https://github.com/TencentARC/GFPGAN
GFPGAN has about 37,697 stars, the most popular of the three. Its code is released under Apache-2.0, but pay close attention: the bundled pretrained weights include DFDNet under CC BY-NC-SA 4.0 (non-commercial) and StyleGAN2 under the NVIDIA license, so the weights themselves carry non-commercial restrictions and commercial use needs caution. Proposed by Tencent ARC Lab, GFPGAN uses a Generative Facial Prior for blind face restoration and enhancement; it brightens, denoises, and rebuilds facial features cleanly, making it ideal for quickly turning a dull, gray face photo into a lively one, and it is the fastest to get started among the three.
Real-ESRGAN
The xinntao/Real-ESRGAN repository, plain address: https://github.com/xinntao/Real-ESRGAN
Real-ESRGAN has about 37,299 stars and the cleanest, most friendly license: BSD-3-Clause. It is positioned as a general-purpose blind image super-resolution model, good at deblurring, removing JPEG compression artifacts, and upscaling small images; it is not a face-specialized model. The models it ships, such as realesrgan-x4plus, realesrnet-x4plus, realesr-animevideov3, and realesr-general-x4v3, are general super-resolution models, not face-specific. Its face enhancement is achieved by internally calling GFPGAN through the --face_enhance option; it does not independently rebuild faces on its own, a point we will stress again below.
A relationship often written wrong
Many articles describe GFPGAN as a component of CodeFormer, which is wrong. GFPGAN and CodeFormer are two independent, parallel projects from different teams: CodeFormer comes from NTU S-Lab (Nanyang Technological University) and GFPGAN from Tencent ARC. When CodeFormer does full-image restoration, it plugs in Real-ESRGAN to upsample the background and face regions, not GFPGAN. In other words, the model CodeFormer actually uses as a "background enhancement plugin" is Real-ESRGAN; realesrgan-x4plus and friends are general super-resolution models, and the face-enhancement role falls to GFPGAN only at that step. Getting this straight keeps you from installing the wrong dependencies or wiring the wrong pipeline, and stops you from assuming that installing CodeFormer automatically brings GFPGAN along.
How to choose: look at the photo first
Selection is not a dilemma; match the photo type to the tool.
For face-dominant old photos, prefer CodeFormer. It ships a fidelity slider w from 0 to 1: smaller w yields more "beautified", higher-quality output, larger w stays closer to the original. If you are restoring a wedding photo of your grandparents and want both a clear face and the original look preserved, CodeFormer gives the most flexibility; for extremely old, broken photos where features are fuzzy, pushing w toward 1 is also more stable.
For overall blur, scans, and general sharpness, prefer Real-ESRGAN. Old archive scans, yellowed documents, and endlessly re-compressed JPEGs are best handled by its deblurring and artifact removal, and its ncnn build needs no CUDA and runs on CPU, making it the most hardware-friendly choice.
For a quick face brighten and denoise, prefer GFPGAN. It is the fastest to get started among the three; the command is simple and the clean build runs on plain CPU Windows, perfect for people who do not want to fiddle with environments.
How to run locally
All three need a Python environment, but the difficulty differs sharply; each is described below.
CodeFormer local setup
You need a conda environment with python=3.8, then pip install -r requirements.txt, and python basicsr/setup.py develop. It depends on PyTorch and CUDA; a GPU is strongly recommended, though CPU works but is slow. The main inference script is inference_codeformer.py. The repo maintains an official Gradio wrapper, and the community offers third-party WebUIs such as dfcode, so command-line avoiders can use a graphical interface and just drag an image in to get a result.
GFPGAN local setup
pip install basicsr facexlib, then pip install -r requirements.txt and python setup.py develop. The main script is inference_gfpgan.py, for example:
python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2It ships a "clean" build that needs no CUDA extension and runs directly on CPU and Windows, the most newcomer-friendly of the three; the version flag -v ranges from 1.2 to 1.4, where 1.3 is more natural and stable across qualities while 1.2 is sharper with a slight beauty touch, so switch as needed.
Real-ESRGAN local setup
The lightest. You can use the Python script way:
python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhanceOr you can download the realesrgan-ncnn-vulkan portable executable, which needs no CUDA and no PyTorch and runs on Intel, AMD, Nvidia GPUs or plain CPU, making it the most hassle-free of the three; adding --face_enhance automatically calls GFPGAN for face enhancement, so one command gives you both a sharp background and a clean face.
License and commercial boundary
This section must be clear, because none of the three is "fully free," and reading only the code license will trip you up.
CodeFormer: the GitHub API license field is NOASSERTION, the README states NTU S-Lab License 1.0, and the pretrained weights are, per statement, limited to research and non-commercial use; commercial use needs extra authorization, so do not assume it is free for business.
GFPGAN: the code is Apache-2.0 and commercially usable, but the weights bundle DFDNet (CC BY-NC-SA 4.0) and StyleGAN2 (NVIDIA license), so the weights themselves carry non-commercial restrictions; using the model inside a commercial product demands extra caution and preferably explicit authorization first.
Real-ESRGAN: BSD-3-Clause, with both code and general-model weights relatively permissive, the lowest commercial risk of the three; but because its --face_enhance calls GFPGAN, once you enable face enhancement that non-commercial constraint comes along, so do not assume using it solves everything.
Conclusion: for personal family photos, research, and non-profit display, all three are safe; for paid restoration services or commercial products, prefer Real-ESRGAN's general super-resolution and seek separate compliant authorization for the face-enhancement part, keeping the boundary in writing.
Practical tips
If this is your first time with such tools, start with Real-ESRGAN's ncnn portable build: zero environment, zero GPU threshold, and you get the "sharpness" layer working first; once the direction is confirmed, move to GFPGAN for face brightening, and finally use CodeFormer for high-fidelity retouching. Going from light to heavy, from general to face, wastes no time on wrong environments and lets you compare the three directly. Also, scan old photos at the highest DPI you can; the clearer the original, the more believable the face details the model fills in, and do not expect a phone snapshot of a blurry print to be brought back to life.
A few output notes save rework. CodeFormer and GFPGAN emit PNG by default, while Real-ESRGAN can also write the upscaled result as a single tile-free image. If you feed a scanned photo, fix rotation and dust first, because every model treats a tilted scan as part of the scene and will happily "restore" the skew along with the face. Keep your originals untouched and write results to a separate folder, so a bad run never overwrites the only copy you have.
When open source is not optimal
Having praised the strengths, a dose of cold water is fair: open-source models are not omnipotent, and in several cases they are not the best answer. First, if you have no command-line background and no willingness to install a Python environment, even the ncnn portable build still asks you to download, unzip, and type commands, a higher bar than "open the mini-program and upload." Second, if a photo is so damaged that the face structure is entirely gone, no model can do more than invent a face from its prior, and the result may look nothing like the real person; such extremes are better left to a professional restorer doing hand retouching. Third, if you need batch, consistent, deliverable commercial service with both stable quality and compliant licensing, the labor and legal cost of building this toolchain yourself may exceed buying a mature solution. Open source gives you control and playfulness; the price is that you become the operator, so think it through before you start.
Online alternatives, in one line
If you do not even want to set up an environment, Tencent, ByteDance, and Alipay all offer old-photo restoration mini-programs: upload and get a result, zero deployment cost, at the price of sending your original to their servers and playing by their rules, with neither the privacy nor the batch freedom of local runs.
FAQ
Q1: Which restores faces best?
For severely degraded photos where features are unreadable, CodeFormer's blind face restoration is the most robust, and its w slider balances "fidelity" against "beautification"; for a quick brighten and denoise, GFPGAN is faster and lighter. Both beat Real-ESRGAN on the face step, whose face enhancement is essentially borrowed from GFPGAN.
Q2: Do I need a graphics card?
CodeFormer and GFPGAN recommend an NVIDIA GPU (CUDA) for a comfortable run; GFPGAN has a clean build for pure CPU, and CodeFormer can also run slowly on CPU. Real-ESRGAN's ncnn build is the least picky and works on CPU. You can run without a discrete GPU, but the speed gap is large, turning a few seconds per photo into several minutes.
Q3: How do I run locally?
Install Python and the matching dependencies first: CodeFormer uses inference_codeformer.py, GFPGAN uses inference_gfpgan.py, and Real-ESRGAN uses inference_realesrgan.py or the downloaded ncnn build. If you fear the command line, CodeFormer and some community projects ship a WebUI where you just click, no need to memorize parameters.
Q4: Can I use it commercially?
Real-ESRGAN (BSD-3-Clause) general super-resolution is safest; CodeFormer weights are research-and-non-commercial only and need extra authorization; GFPGAN code is commercial but its weights carry non-commercial limits. For paid restoration, untangle each model's license first and do not read only the code license.
Q5: How does it compare with online mini-programs?
Online mini-programs need zero setup and are quick to start, but your original is uploaded, processed by their rules, and hard to batch or customize; local open-source models keep data on your machine, give controllable parameters, and allow batching, at the cost of setting up an environment and using hardware. For privacy-sensitive cases or a whole box of photos, local wins.
Related reading