Transform old photos into stunning portraits with CodeFormer

Discover the magic of CodeFormer as it breathes new life into old, worn-out photographs, transforming them into stunning, high-quality portraits. In this post, we'll explore how CodeFormer works and showcase some amazing before-and-after examples.

Transform old photos into stunning portraits with CodeFormer

Blind Face restoration is the process through which we recover high-quality faces from face images that have undergone complex or unknown degradations. It involves restoring these facial images without access to clear references.

The restoration processes often grapple with challenges related to the absence of well-defined mappings from degraded inputs to desired outputs. Additionally, there is a significant loss of high-quality details present in the original images.

To address all these complexities involved with blind face restoration, CodeFormer was introduced. It captures intricate composition and details that are present in low-quality facial images. Thus it stands out as a robust model addressing the complexities involved in face restoration.

In this blog post, we will take a close look into how the Codeformer model can be used to transform old degraded photos into stunning portraits.

How Codeformer works?

The process begins by acquiring a discrete codebook and a decoder through self-reconstruction learning to effectively store the high-quality visual components of the facial images. Once the codebook and decoder are fixed, the transformer module is introduced which helps in predicting the code sequence thus enabling face composition for low-quality inputs.

A controllable feature transformation module is present which helps in regulating the information flow from the low-quality encoder to the decoder. It's crucial to note that this connection is optional and can be disabled to prevent adverse effects, particularly in cases of severely degraded inputs.

Why restore old photos?

As years have passed by we get to see that restoration of damaged photos serves a vital purpose in preserving visual memories and historical moments. Photos undergo various forms of damage such as wear, tear, fading, or other degradation. These degradations may arise due to multiple reasons ranging from environmental factors, and aging to mishandling.

Efficient restoration methods, like those employed by advanced models such as CodeFormer, play a crucial role in salvaging these valuable visual artifacts. Models like these not only help maintain the integrity of the original content but also allow us to relive and share cherished moments with clarity and vibrancy.

Having already explored the optimal settings for the CodeFormer model, we will now leverage those insights to transform the old degraded photos.

How to restore old photos or portraits using CodeFormer?

The vintage photograph featuring the renowned scientist Marie Curie presents a captivating yet challenging restoration task. Preserved in a sepia tone, the image bears the unmistakable marks of time and inadequate handling, manifesting as blurred details and diminished clarity

The transformer module is present in CodeFormer helos in global face composition prediction. This not only unravels the intricate details present in the picture such as the texture of her hair and skin but also helps in balancing quality and fidelity.

The restored image not only has enhanced details of the texture of the hair but has also preserved the original texture of the skin as well.

Let us take the old photograph of the Indian freedom fighter Mahatma Gandhi, The image characterized by a dull and faded appearance, lacks the vibrancy and depth that would do justice to the historical significance of the iconic figure.

The wear and tear is quite evident in the photo, particularly in the upper part where pixelation compromises the clarity of the image., through adjustments in the fidelity values we can ensure that the portrait captures the essence of the image with high clarity.

Take a look at this old black-and-white photo of the esteemed scientist Homi J. Bhabha that reflects the passage of time, especially in the faded color tones that take away from the image's visual charm.

CodeFormer not only brings back the lost color intricacies but also adds a touch that enhances the overall charm of the portrait. Not only does it get to fix the faded hues, but it also breathes life into the grayscale images capturing the essence that was intended in the original. It helps in giving the image a refreshed visual appeal and preserves the image.

In this wide shot from the iconic Dollars Trilogy movie "A Fistful of Dollars," featuring the legendary Clint Eastwood, the limitations of the 1964 camera technology are evident, leading to a diminished visual quality over time. As this spaghetti Western holds a special place in cinematic history, we can now restore the image to look at its full glory.

The original camera's constraints, prevalent in the wide shot, pose challenges such as pixelation and lack of clarity. CodeFormer helps in enhancing the details while also preserving the authenticity of the Dollars trilogy.

Here is an old photograph of one of the finest tennis players the game has ever witnessed, Rod Laver. These vintage photographs carry their unique charm providing a glimpse of the past.

Whether it's the intensity in Laver's gaze or the nuances of the surroundings and texture of the skin, the restoration process can uncover layers of the image that may have been concealed by the passage of time.

Take this particular image of Amitabh Bachchan, the Indian actor in the iconic movie “Sholay” which holds immense cultural and cinematic significance, encapsulating a pivotal era in Indian cinema. However, with time, such cherished visuals can undergo degradation, manifesting as faded colors and diminished quality.

By using CodeFormer we we get to address color fading and enhance the overall details present in the image. The restoration process may unveil details lost to time, allowing audiences to reconnect with the vibrancy and brilliance of the film in its original glory.

Finally, we will take this image of young Bill Gates, adorned with glasses that stand as a nostalgic glimpse into the formative years of one of the tech industry’s most influential figures.

We get to see how the restored image on the right highlights the contours of hair while elevating the overall image quality.


As time flies by, cherished images often bear the brunt of various adversities from natural decay to technological limitations. Factors such as fading colors, pixelation, and overall degradation can compromise the visual richness of historical photographs, robbing them of their intrinsic charm. Models like CodeFormer can not only help us preserve the historical and cultural legacy of the images but also offer a renewed viewing experience.

*Sign up on Segmind now and receive 100 free inferences every day.