Table of contents
GFPGAN and Codeformer are two models that can fix faces in images.
They are both fast and can be run in the cloud with an API. They are particularly useful as models to run against images generated by other AI models, especially older ones.
TencentArc’s GFPGAN has long been the go to model for fixing faces in images. Whether that’s correcting them while upscaling, or fixing the mistakes in faces generated by AI.
It is very good at:
It does not:
Use it in modern workflows alongside other upscalers. Fix faces with GFPGAN, then upscale with another model.
In this example a Midjourney image from 2022 is fixed using GFPGAN in 2.6s.
See how well the eyes are fixed, but also note how some skin blemishes are removed. The sharpening of the soft focus is also noticeable and undesirable.
In another example we can see how GFPGAN fixes the face in an old victorian photo. The face looks really good and much of the identity is preserved. However there are still JPEG artefacts and picture damage.
We recommend using GFPGAN via the Real-ESRGAN model on Replicate. Turn on the face_enhance
option to enable GFPGAN.
Read about running Real-ESRGAN + GFPGAN with an API.
In this comparison, we compare GFPGAN and Real-ESRGAN:
Codeformer by sczhou is another choice for fixing badly generated AI faces.
Unlike GFPGAN, it will typically leave alone any part of the image that is not a face (you can optionally enhance the background with Real-ESRGAN).
It also takes a more heavy-handed approach to fixing faces. This means it can fix the very worst of AI faces, but when fixes need to be subtle it can degrade likeness.
It is very good at:
It does not work well with:
In these cases it can get confused and return distorted and broken results.
In this example, using the same Midjourney image as before, Codeformer fixes the face in 3s.
Notice that the edges of the image are unchanged. The eyes are fixed and the face is improved, albeit they look a little different. Like GFPGAN the skin blemishes have also been removed.
In another example we can see how Codeformer fixes the face in an old victorian photo. The face looks really good and much of the identity is preserved. However there are still JPEG artefacts and picture damage.
GFPGAN and Codeformer are both good at fixing faces.
If you want to maintain likeness, use GFPGAN. If the face you need to fix is really bad, try Codeformer. But otherwise they are very similar.
And the Victorian example: