A list of face restoration papers and codes, can see in this repository .
- 2024.11.03: Add GFPGAN、CodeFromer 、GPEN inference codes.
- Add torch2onnx script
- Add more face restoration method
-
Clone repo
git clone https://github.com/yeruiqian/Face_Restoration.git cd Face_Restoration
-
Install dependent packages
# Install basicsr - https://github.com/xinntao/BasicSR pip install basicsr # Install facexlib - https://github.com/xinntao/facexlib pip install facexlib # you also can refer to my own environment 'requirements_self.txt' pip install -r requirements.txt python setup.py 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
download the weights and put them in experiments/pretrained_models
'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth'
'https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth'
'https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-512.pth'
python inference.py -i inputs/cropped_faces -o results/GPEN -v GPEN -s 1
python inference.py -i inputs/cropped_faces -o results/GFPGAN1.4 -v GFPGANv1.4 -s 1
python inference.py -i inputs/cropped_faces -o results/CodeFormer -v CodeFormer -s 1
Usage: python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2 [options]...
-h show this help
-i input Input image or folder. Default: inputs/cropped_faces
-o output Output folder. Default: results
-v version Different model. Option: GFPGANv1.4,GPEN,CodeFormer. Default: GFPGANv1.4
-s upscale The final upsampling scale of the image. Default: 2
-bg_upsampler background upsampler. Default: realesrgan
-bg_tile Tile size for background sampler, 0 for no tile during testing. Default: 400
-suffix Suffix of the restored faces
-only_center_face Only restore the center face
-aligned Input are aligned faces
-ext Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto
This project is based on BasicSR. Codes are brought from GFPGAN、CodeFromer 、GPEN. Thanks for their awesome works.