Skip to content
Switch branches/tags
This branch is up to date with master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


download PyPI Open issue Closed issue LICENSE python lint Publish-pip


This repo is for readers from the blogpost linked here:
[Coming 12/9/2021]

Instructions to set up and use on Gradient notebook:

  1. In "Create a Notebook" page, select PyTorch Runtime and any GPU
  2. Toggle advanced options at bottom of page, and set workplace url as
  3. Launch notebook
  4. Put any photos you want to upscale into "inputs/whole_imgs"

Use this notebook to follow along and reproduce the materials found in the blog

  1. We provide a clean version of GFPGAN, which can run without CUDA extensions. So that it can run in Windows or on CPU mode.

GFPGAN aims at developing Practical Algorithm for Real-world Face Restoration.
It leverages rich and diverse priors encapsulated in a pretrained face GAN (e.g., StyleGAN2) for blind face restoration.

🚩 Updates

  • Integrated to Huggingface Spaces with Gradio. See Gradio Web Demo.
  • Support enhancing non-face regions (background) with Real-ESRGAN.
  • We provide a clean version of GFPGAN, which does not require CUDA extensions.
  • We provide an updated model without colorizing faces.

If GFPGAN is helpful in your photos/projects, please help to this repo or recommend it to your friends. Thanks😊 Other recommended projects:
▶️ Real-ESRGAN: A practical algorithm for general image restoration
▶️ BasicSR: An ppen-source image and video restoration toolbox
▶️ facexlib: A collection that provides useful face-relation functions.
▶️ HandyView: A PyQt5-based image viewer that is handy for view and comparison.

📖 GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior

[Paper]   [Project Page]   [Demo]
Xintao Wang, Yu Li, Honglun Zhang, Ying Shan
Applied Research Center (ARC), Tencent PCG

🔧 Dependencies and Installation


We now provide a clean version of GFPGAN, which does not require customized CUDA extensions.
If you want want to use the original model in our paper, please see for installation.

  1. Clone repo

    git clone
    cd GFPGAN
  2. Install dependent packages

    # Install basicsr -
    # We use BasicSR for both training and inference
    pip install basicsr
    # Install facexlib -
    # We use face detection and face restoration helper in the facexlib package
    pip install facexlib
    pip install -r requirements.txt
    python develop
    # If you want to enhance the background (non-face) regions with Real-ESRGAN,
    # you also need to install the realesrgan package
    pip install realesrgan

Quick Inference

Download pre-trained models: GFPGANCleanv1-NoCE-C2.pth

wget -P experiments/pretrained_models


python --upscale 2 --test_path inputs/whole_imgs --save_root results

If you want want to use the original model in our paper, please see for installation and inference.

🏰 Model Zoo

  • GFPGANCleanv1-NoCE-C2.pth: No colorization; no CUDA extensions are required. It is still in training. Trained with more data with pre-processing.
  • GFPGANv1.pth: The paper model, with colorization.

You can find more models (such as the discriminators) here: [Google Drive], OR [Tencent Cloud 腾讯微云]

💻 Training

We provide the training codes for GFPGAN (used in our paper).
You could improve it according to your own needs.


  1. More high quality faces can improve the restoration quality.
  2. You may need to perform some pre-processing, such as beauty makeup.


(You can try a simple version ( options/train_gfpgan_v1_simple.yml) that does not require face component landmarks.)

  1. Dataset preparation: FFHQ

  2. Download pre-trained models and other data. Put them in the experiments/pretrained_models folder.

    1. Pretrained StyleGAN2 model: StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth
    2. Component locations of FFHQ: FFHQ_eye_mouth_landmarks_512.pth
    3. A simple ArcFace model: arcface_resnet18.pth
  3. Modify the configuration file options/train_gfpgan_v1.yml accordingly.

  4. Training

python -m torch.distributed.launch --nproc_per_node=4 --master_port=22021 gfpgan/ -opt options/train_gfpgan_v1.yml --launcher pytorch

📜 License and Acknowledgement

GFPGAN is released under Apache License Version 2.0.


    author = {Xintao Wang and Yu Li and Honglun Zhang and Ying Shan},
    title = {Towards Real-World Blind Face Restoration with Generative Facial Prior},
    booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
    year = {2021}

📧 Contact

If you have any question, please email or


GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration.







No packages published