PyTorch codes for "Progressive Semantic-Aware Style Transformation for Blind Face Restoration"
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
git clone https://github.com/chaofengc/PSFR-GAN.git cd PSFR-GAN
pip3 install -r requirements.txt
Download the pretrained models from the following link and put them to
./pretrain_models
4uip
Run the following script to enhance face(s) in single input
python test_enhance_single_unalign.py --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
results_dir/LQ_faces
results_dir/ParseMapsand
results_dir/HQ
results_dir/hq_final.jpg
--gpusto specify how many GPUs to use,
<=0means running on CPU. The program will use GPU with the most available memory. Set
CUDA_VISIBLE_DEVICEto specify the GPU if you do not want automatic GPU selection.
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_dir_align_results
For images (e.g.
multiface_test.jpg) contain multiple faces, the aligned faces will be stored as
multiface_test_{face_index}.jpg
python test_enhance_dir_align.py --src_dir test_dir_align_results --results_dir test_dir_enhance_results
results_dir/lq,
results_dir/parse,
results_dir/hq.
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 test_enhance_dir_unalign.py --src_dir test_dir --results_dir test_unalign_results
test_enhance_single_unalign.pyfor each image in
src_dir
@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}, Journal = {arXiv preprint arXiv:2009.08709}, year = {2020} }
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.