Skip to content

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

License

Notifications You must be signed in to change notification settings

chaofengc/PSFRGAN

Repository files navigation

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
  • Python 3.7, install required packages by pip3 install -r requirements.txt
  • Clone this repository
    git clone https://github.com/chaofengc/PSFR-GAN.git
    cd PSFR-GAN
    

Download Pretrain Models and Dataset

Download the pretrained models from the following link and put them to ./pretrain_models

Test single image

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

python test_enhance_single_unalign.py --test_img_path ./test_dir/Solvay_conference_1927.jpg --results_dir solvay_test --test_upscale 1

This script do the following things:

  • Crop and align all the faces from input image, stored at solvay_test/LQ_faces
  • Parse these faces and then enhance them, results stored at solvay_test/ParseMaps and solvay_test/HQ
  • Paste then enhanced faces back to the original image solvay_test/hq_final.jpg
  • You may use --test_upscale to upscale the final output.

Test image folder

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

python align_and_crop_dir.py --src_dir test_dir --results_dir test_align_results

For images (e.g. multiface_test.jpg) contain multiple faces, the aligned faces will be stored as multiface_test_{face_index}.jpg
And then parse the aligned faces and enhance them with

python test_enhance_dir_align.py --dataroot test_align_results --results_dir test_enhance_results

Results will be saved to three folders respectively: lq, parse, hq.
Note: This is used to test a large amounts of data, so we do not paste the faces back.

Citation

@InProceedings{ChenPSFRGAN,
    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},
    year = {2020}
}

License

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

Acknowledgement

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages