Need help with PSFRGAN?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

164 Stars 31 Forks Other 25 Commits 0 Opened issues


PyTorch codes for "Progressive Semantic-Aware Style Transformation for Blind Face Restoration"

Services available


Need anything else?

Contributors list

PSFR-GAN in PyTorch

We only provide test codes at this time.

Progressive Semantic-Aware Style Transformation for Blind Face Restoration
Chaofeng Chen, Xiaoming Li, Lingbo Yang, Xianhui Lin, Lei Zhang, Kwan-Yee K. Wong

Getting Started

Prerequisites and Installation

  • Ubuntu 18.04
  • CUDA 10.1
  • Clone this repository
    git clone
    cd PSFR-GAN
  • Python 3.7, install required packages by
    pip3 install -r requirements.txt

Download Pretrain Models and Dataset

Download the pretrained models from the following link and put them to


- GoogleDrive - BaiduNetDisk, extract code:

Test single image

Run the following script to enhance face(s) in single input

python --test_img_path ./test_dir/test_hzgg.jpg --results_dir test_hzgg_results --gpus 1

This script do the following things: - Crop and align all the faces from input image, stored at


- Parse these faces and then enhance them, results stored at

- Paste then enhanced faces back to the original image

- You can use
to specify how many GPUs to use,
means running on CPU. The program will use GPU with the most available memory. Set
to specify the GPU if you do not want automatic GPU selection.

Test image folder

To test multiple images, we first crop out all the faces and align them use the following script.

python --src_dir test_dir --results_dir test_dir_align_results

For images (e.g.

) contain multiple faces, the aligned faces will be stored as

And then parse the aligned faces and enhance them with
python --src_dir test_dir_align_results --results_dir test_dir_enhance_results

Results will be saved to three folders respectively:

Additional test script

For your convenience, we also provide script to test multiple unaligned images and paste the enhance results back. Note the paste back operation could be quite slow for large size images containing many faces.

python --src_dir test_dir --results_dir test_unalign_results

This script basically do the same thing as
for each image in


    author = {Chen, Chaofeng and Li, Xiaoming and Lin, Xianhui and Lingbo, Yang and Zhang, Lei and Wong, KKY},
    title = {Progressive Semantic-Aware Style Transformation for Blind Face Restoration},
    Journal = {arXiv preprint arXiv:2009.08709},
    year = {2020}


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


This work is inspired by SPADE, and closed related to DFDNet and HiFaceGAN. Our codes largely benefit from CycleGAN.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.