كل الأدلة

CodeFormer vs GFPGAN: What's the Difference, and Which Should You Use?

CodeFormer.io teamنُشر في
Last checked: October 2026

CodeFormer vs GFPGAN, the short answer: for a blurry or badly damaged face in an old family photo, try CodeFormer first. If the result looks over-textured, run GFPGAN version 1.4 on the same scan and compare. For faces in AI-generated images, some people run both.

Both are research models that rebuild soft or damaged faces, and both have their code on GitHub. GFPGAN came first, from Tencent in 2021. CodeFormer followed in 2022 from Nanyang Technological University in Singapore, and it adds a dial that sets how closely the new face follows your photo.

  • Illustration of the smooth and textured looks users describe in CodeFormer vs GFPGAN comparisons

    Blurry original

  • Smoother look users describe

    Smoother look users describe

  • More texture users describe

    More texture users describe

Illustration: the person is AI-generated, and the right-hand panels show the looks users describe. Neither model made them.

CodeFormer vs GFPGAN at a glance

Year and conferenceGFPGAN2021, CVPRCodeFormer2022, NeurIPS
Made byGFPGANXintao Wang and colleagues, Tencent ARCCodeFormerShangchen Zhou and colleagues, S-Lab, NTU Singapore
How it worksGFPGANA face generator that already knows faces, guided by your photoCodeFormerA Transformer picks from 1,024 stored face pieces
Closeness dialGFPGANNone; you pick a version (V1 to V1.4), and apps such as AUTOMATIC1111 add a strength sliderCodeFormerWeight w from 0 to 1 (default 0.5): lower looks cleaner, higher stays closer to the original
Typical look, per usersGFPGANSmooth, sometimes airbrushedCodeFormerMore skin texture; can replace real freckles
Adds color / fills in missing partsGFPGANOnly the V1 model adds color to faces; no fill-in modelCodeFormerA separate model for each, on cropped faces only
License, commercial useGFPGANApache 2.0, but some bundled parts are non-commercialCodeFormerS-Lab License 1.0: non-commercial only (commercial use: ask the authors)
Official codeGFPGANTencentARC/GFPGAN on GitHub, last release Sept. 2022CodeFormersczhou/CodeFormer on GitHub, last update Nov. 2025

Sources: the GFPGAN paper, the CodeFormer paper and both GitHub repositories, checked October 2026.

How each one works, in plain words

What is GFPGAN?

GFPGAN is Tencent's face restoration model. It starts from a face generator that already knows what faces look like (StyleGAN2), and your photo guides it, so it can draw a believable eye or lip. GFPGAN itself was trained on FFHQ, a set of 70,000 high-quality face photos.

The catch: part of each face comes from the generator's idea of a face. GFPGAN's own README says version 1.3 can shift identity slightly, and that 1.4 keeps it a little better.

What is CodeFormer?

CodeFormer works more like a jigsaw puzzle. First it learns a "codebook" of 1,024 small, high-quality face pieces. Then a Transformer, a kind of AI that takes in the whole face at once, predicts which piece goes where.

Every answer has to come from that set of good pieces, so a badly damaged face is less likely to turn to mush. The weight w then decides how much of your own photo gets mixed back in. Low gives a cleaner, more rebuilt face; high stays closer to the person in the scan.

And RestoreFormer?

RestoreFormer is a third face model, by Zhouxia Wang and colleagues (CVPR 2022). GFPGAN's repository can run it too.

What the CodeFormer paper's own tests show

Of the two models' own papers, only CodeFormer's puts both in one table, and the CodeFormer team wrote it. Read the numbers as the authors' results, not a neutral verdict.

On 3,000 test faces that a computer blurred and damaged on purpose, CodeFormer's results matched the real person better (0.60 vs 0.42 on an identity score). GFPGAN scored slightly better on realism (58.36 vs 60.62, where lower is better).

On real photos the split depends on the damage. GFPGAN scored better on realism for lightly damaged faces, while CodeFormer did better on medium damage and on a set of 970 badly damaged faces.

Speed won't decide it. One 512 × 512 face took 0.070 seconds with CodeFormer and 0.126 with GFPGAN on a Tesla V100 graphics card. GFPGAN's own paper used a different test setup, so its numbers can't be compared with any of these.

GFPGAN vs CodeFormer: what users report

Most GFPGAN vs CodeFormer opinions we found come from Stable Diffusion users in 2022 to 2024, fixing faces an AI drew rather than scanned prints. If your question is old family photos, they only get you partway.

Opinions split. In a September 2022 test on r/StableDiffusion, the tester called GFPGAN faces "a little too smooth, textureless, and digital." The same tester liked CodeFormer's realistic skin at full strength but found it weaker at fixing where the eyes point, and a 2023 reply said it can replace real freckles with texture of its own.

Another commenter said CodeFormer in AUTOMATIC1111 generally gave bad or warped results. The top answer in an October 2022 thread says both have strengths and weaknesses, and its writer mixes the two.

Which is better for old photos?

For an old family photo, CodeFormer is a fair first try. In its authors' own tests it held up better on badly damaged faces. Treat that as a hint, not proof.

Start the weight at 0.7, the value in the README's whole-photo example. If Grandpa begins to look like a stranger, raise it; if his face still looks soft, lower it.

GFPGAN gives you fewer handles: a version to pick and, in apps, a strength slider. If CodeFormer adds more skin texture than the person really had, run GFPGAN 1.4 on the same scan and put the two results side by side.

Some limits apply to both:

  • They work on faces only. Each face is cut out, restored and pasted back, so a crease through a shirt or the sky usually needs another tool. CodeFormer's README also warns that the pasting step can damage hair texture at the edge.
  • Both papers admit weak results on strongly turned heads, such as a side profile.
  • If a stain covers the eyes, any model can only invent new ones.

Start from a flat scan at 600 DPI (how to scan old photos).

  • Three old photos: a soft front-facing face, a side profile, and a crease through the background

    Face models do well

  • Both struggle

    Both struggle

  • Not a face model's job

    Not a face model's job

Sample photos: the people are AI-generated.

CodeFormer or GFPGAN for Stable Diffusion?

With AI-generated faces nobody has to recognize the person, so choosing CodeFormer or GFPGAN for Stable Diffusion is a matter of taste. GFPGAN at partial strength gives a soft, even fix. CodeFormer, the default in AUTOMATIC1111, adds more skin detail. Some people run both.

Can you use both together?

Yes. AUTOMATIC1111's Stable Diffusion WebUI has both built in.

  1. While generating: in Settings > Face restoration, turn on Restore faces, pick a model and set CodeFormer weight (default 0.5). Careful: its label reads "0 = maximum effect; 1 = minimum effect", which tripped up the 2022 tester. This uses one model.
  2. On any image: the Extras tab has a GFPGAN section with a visibility slider and a CodeFormer section with visibility and weight. Turn both on. The Extras weight starts at 0, which means full effect.
  3. Find your mix: the 2022 tester got the best face by running GFPGAN first, then CodeFormer. A 2023 reply's blend: GFPGAN at about 0.5, CodeFormer weight near 0.

In ComfyUI, the facerestore_cf custom node loads both.

CodeFormer vs GFPGAN licenses: can you use them commercially?

CodeFormer uses the S-Lab License 1.0: non-commercial use only; for commercial use, contact the authors. That holds wherever it runs, Colab and AUTOMATIC1111 included.

GFPGAN's license file says Apache 2.0, which normally allows business use, but it carves out bundled third-party parts. Two are non-commercial: StyleGAN2 code under NVIDIA's license (research or evaluation only) and DFDNet code under CC BY-NC-SA 4.0. Both models were also trained on FFHQ, a dataset released for non-commercial use; what that means for the models is a legal question.

So GFPGAN's terms are friendlier, but neither is plainly free for business. This isn't legal advice; ask a lawyer before selling restorations or building a product.

GFPGAN online and CodeFormer online: the official demos

Both can be tried without installing, with strings attached (checked October 2026):

  • CodeFormer: the authors' Hugging Face demo is running. Logged-out visitors get 2 minutes of shared GPU time a day, photos over 4 megapixels are refused, and you have 30 seconds to save the result. Replicate needs a GitHub sign-in and charges per run after a limited number of free ones.
  • GFPGAN: both Hugging Face demos linked from its README showed a runtime error. That leaves Replicate, on the same terms, and an official Colab notebook we didn't test.

CodeFormer's README links a Colab notebook too, where you sign in with Google and run the code cells yourself. More on each CodeFormer route: how to use CodeFormer.

If you just want an old photo fixed

CodeFormer.io is an independent website that restores old photos online, in your browser, with nothing to install. It isn't affiliated with the CodeFormer authors, S-Lab or NTU.

Its AI is instructed to repair the whole print, faces included: scratches, creases and fading as well as blur and grain. Check every result, since AI can fill in fine detail and can't bring back a face that's torn away.

Your first photo each day is free, with no account and no watermark. A photo usually takes 1 to 3 minutes. Paid credits add 2K and 4K output (pricing).

Came for GFPGAN in particular? gfpgan.io, our sister site, has a page about it. It's independent too, not the official GFPGAN project.

Old photo of a grandfather restored online in a browser
قبلبعد
Sample photo: the grandfather is AI-generated; the restored version is a real, unedited result from this tool.

FAQ

What is GFPGAN face restoration used for?

Mostly two jobs: sharpening soft faces in old or low-quality photos, and cleaning up faces in images made with Stable Diffusion.

Where can I use GFPGAN online?

On Replicate, the one official route we found working in October 2026. The demos section above has the sign-in and cost details.

Is RestoreFormer better than CodeFormer or GFPGAN?

We can't say. Neither paper ranks RestoreFormer against both, so the fair test is your own scan run through all three.

Can either one colorize black-and-white photos?

Not a whole photo. GFPGAN's V1 model adds color to faces, though its paper warns the color can be off on black-and-white input, and later versions skip color. CodeFormer's colorization model works on a cropped face only. For a whole print, our colorize old photos page starts with Bring back color already selected.

Is CodeFormer.io the official CodeFormer website?

No. CodeFormer.io is independent and isn't affiliated with the CodeFormer authors, S-Lab or Nanyang Technological University. The official code is on GitHub; you install it on your own computer, which takes some technical skill.

ما الجديد في هذه الصفحة

  • — Published. Demos, licenses and code repositories checked in October 2026.
عرض كل الأدلة