Machine Learning in Linux

Machine Learning in Linux: GFPGAN – Face restoration software

Last Updated on March 6, 2023

In Operation

There is no fancy GUI. Instead, you run the software from the command-line. For example, to use the default model (v1.3), we can issue the command:

$ python inference_gfpgan.py -i [Graphic_file.png] -o results -v 1.3 -s 2

The -v flag tells the software which version of the pre-trained model to use, -s tells the software how much to upscale the image. Actually if you want to use v1.3 and upscale by 2, you don’t need the flags as they are the defaults.

To experiment with v1.2 or v1.4 use the flag -v 1.2 or -v 1.4. Each pre-trained model is automatically downloaded if it’s not already present.

Here’s example output with v1.3 of the model. The image on the left is the original very low quality image, the image on the right hand side is the output. What a transformation!

Image
Click image for full size

We’re only showing the cropped comparison face, but the software also generates the restored image, and separate images of the original and restored face.

For this image, the results from v1.3 and v1.4 were very close, and superior to v1.2. Which model produces the best outcome depends on the image itself.

Summary

GFPGAN is really impressive software for restoring poor quality images of faces. Some of the results are truly remarkable.

The results are definitely not perfect with evidence that restoration is not completely natural. For example, the pre-trained models are poor at treating freckles and wrinkles, effectively airbrushing them out to a significant degree. It reminds us of an article recently published in the Telegraph which depicted a woman who spent £100,000 on cosmetic surgery and how much it’s likely to have transformed her appearance. GFPGAN applies that type of beauty enhancement to photos without the outlay but, of course, only virtually.

GFPGAN offers GPU support, and a good choice of pre-trained models. GFPGAN also enhances the background (non-face) regions with Real-ESRGAN, software which uses algorithms for general image/video restoration.

GFPGAN has amassed a stonking 26k GitHub stars.

If you want to try v1 of the pre-trained model, you need to recompile the software with some changes.

Website: github.com/TencentARC/GFPGAN
Support:
Developer: THL A29 Limited
License: Apache License Version 2.0

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

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

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.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Noel
Noel
1 year ago

Did you install the software in Ubuntu?