Skip to main content

Face Restoration with GFPGAN

Victoria Harbour, Hongkong

Github Repository

Project Setup

This project uses the GFPGAN repository available on Github:

git clone https://github.com/mpolinowski/GFPGAN

And we will be using a pre-trained model that can be downloaded from here. There are different models available - one of them does not rely on a CUDA-Extensions (can be run on a CPU). But the following one does require an nVidia graphics card:

cd GFPGAN
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models

Install Dependencies

All dependencies are listed in the requirements.txt file:

torch>=1.7
numpy<1.21 # numba requires numpy<1.21,>=1.17
opencv-python
torchvision
scipy
tqdm
basicsr>=1.3.4.0
facexlib>=0.2.0.3
lmdb
pyyaml
tb-nightly
yapf
pip3 install -r requirements.txt

If you want to enhance the background (non-face) regions with Real-ESRGAN, you also need to install the realesrgan package:

pip3 install realesrgan

And run the setup script:

python setup.py develop

Run Up-Sampling

We can run the following script included inside the repository to feed images from the ./inputs/whole_imgs directory into our GAN and output the up-sampled images into the ./results folder:

python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2

Results

ESRGAN Super Resolution

ESRGAN Super Resolution