Artificial Intelligence

Machine Learning in Linux: CodeFormer – face restoration

In Operation

CodeFormer is command-line software, there’s no GUI available.

For a face that has already been cropped and aligned, we can use the following syntax for Face Restoration.

$ python inference_codeformer.py -w 0.5 --has_aligned --input_path [image folder]|[image path]

Here’s an example of the restoration.

CodeFormer
Click image for full size

For whole image enhancement, we can use Real-ESRGAN to restore the background regions and upsample the face with Real-ESRGAN

$ python inference_codeformer.py -w 0.7 --input_path [image folder]|[image path] --face_upsample --bg_upsampler realesrgan

The software uses the RealESRGAN_x2plus model. For many pictures, the RealESRGAN_x4plus model can offer better results for background enhancement, but this isn’t available here.

Summary

CodeFormer is an interesting project both from a technical perspective and from the quality of its output. The results are impressive particularly when you add the improvements offered by Real-ESRGAN.

We were attracted to the project in part because the project promotes face colour enhancement. But the reality is that the developers have no plan to release their colorization model.

There is support for video enhancement but we haven’t tested this functionality.

CodeFormer has been integrated into Stable Diffusion web UI and InvokeAI, two projects that offer a web front end to Stable Diffusion.

Bear in mind that CodeFormer is not released under an open source license. The license doesn’t permit redistribution and/or use for commercial purpose in source or binary forms, with or without modification.

Website: github.com/sczhou/CodeFormer
Support:
Developer: S-Lab, Nanyang Technological University
License: S-Lab License 1.0 (not open source)

Artificial intelligence icon For other useful open source apps that use machine learning/deep learning, we’ve compiled this roundup.

CodeFormer is written in Python. Learn Python with our recommended free books and free tutorials.

Pages in this article:
Page 1 – Introduction and Installation
Page 2 – In Operation and Summary

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments