Almost a year ago, Tencent researchers released their GFPGAN Face Restoration AI model, which is trained, specifically on faces, to upscale and restore details in low-resolution or damaged portrait photos. I thought I’d give it a whirl.

I first saw a post on Reddit which led me to an article by Louis Bouchard, Impressive photo restoration by AI! and accompanying video on YouTube. Since then, Engadget also picked it up, so I figure others would be interested to try.

Danger. Do not blindly copy! I don’t know what I’m doing, but it works for me. I seriously know nothing about AI or machine learning.

This is not a review or a tutorial and certainly this is not the correct way to build a Docker container... I’m just doing what is expedient and recording the instructions I pieced together from here and there to try out the model. I would rather run it in a container, air-gapped if necessary... just so that I am sure.

The only pre-requisite is Docker. No GPU (or CUDA) acceleration required, unlike a lot of other models. Therefore, I am using my Multipass setup on an M1 mac.

Everything needed is in the GFPGAN GitHub, including the code, pre-trained models v1.2 and v1.3 and test images, making it super simple to use. The steps below download what is needed in an Anaconda image, and then run the sample images through the model.

# in the Multipass docker VM, start an instance of Anaconda
docker pull continuumio/anaconda3
docker run -it --name anaconda -p 8080:8080 -p 8888:8888 continuumio/anaconda3 /bin/bash

# in the Anaconda container, install OpenGL
apt update
apt install -y libgl1-mesa-glx

## optionally, install Jupyter Notebooks
conda install jupyter -y --quiet
mkdir -p /opt/notebooks
cd /opt/notebooks/
# jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root &

# optionally, install FileBrowser to easily upload/download files
curl -fsSL | bash
filebrowser -a -p 8080 -r /opt/notebooks &

# get the GFPGAN source code and pre-trained models
git clone
wget -P experiments/pretrained_models
wget -P experiments/pretrained_models

# install Python pre-requisites
pip install basicsr
pip install facexlib
pip install -r requirements.txt
python develop
pip install realesrgan

# upgrade NumPy, otherwise pytorch/.../tensor_numpy.cpp complains "module compiled against API version 0xf"
pip install -U numpy

# test using the provided images, and check the results folder
python -i inputs/whole_imgs -o results -v 1.3 -s 2

Good luck!