G F P G A Nv1
TencentARCIntroduction
GFPGAN (Generative Facial Prior GAN) is a blind face restoration algorithm that utilizes generative facial priors to enhance the quality and realism of face images, particularly when dealing with low-quality inputs. It achieves high-quality restoration by incorporating rich priors through a pretrained face GAN.
Architecture
GFPGAN leverages a Generative Facial Prior embedded in a pretrained GAN model. This is integrated into the restoration process using channel-split spatial feature transform layers. These layers allow a balance between realness and fidelity, enabling the restoration of facial details and color enhancement in a single forward pass.
Training
The training process for GFPGAN involves several steps:
- Dataset Preparation: Use the FFHQ dataset.
- Pre-trained Model Downloads: Obtain the StyleGAN2 model, component locations of FFHQ, and a simple ArcFace model.
- Configuration: Modify the
train_gfpgan_v1.yml
file as needed. - Execution: Run the training using distributed PyTorch with the given command.
Guide: Running Locally
To run GFPGAN locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/xinntao/GFPGAN.git cd GFPGAN
-
Install Dependencies:
- Install BasicSR and facexlib:
BASICSR_EXT=True pip install basicsr pip install facexlib
- Install other requirements:
pip install -r requirements.txt
- Install BasicSR and facexlib:
-
Download Pre-trained Models:
wget https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth -P experiments/pretrained_models
-
Run Inference:
python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs
For optimal performance, use cloud GPUs like those offered by Google Colab or AWS.
License
GFPGAN is released under the Apache License Version 2.0.