CVPR/GFPGAN-example
6
1# Installation2 3We now provide a *clean* version of GFPGAN, which does not require customized CUDA extensions. See [here](README.md#installation) for this easier installation.<br>4If you want want to use the original model in our paper, please follow the instructions below.5 61. Clone repo7 8 ```bash9 git clone https://github.com/xinntao/GFPGAN.git10 cd GFPGAN11 ```12 131. Install dependent packages14 15 As StyleGAN2 uses customized PyTorch C++ extensions, you need to **compile them during installation** or **load them just-in-time(JIT)**.16 You can refer to [BasicSR-INSTALL.md](https://github.com/xinntao/BasicSR/blob/master/INSTALL.md) for more details.17 18 **Option 1: Load extensions just-in-time(JIT)** (For those just want to do simple inferences, may have less issues)19 20 ```bash21 # Install basicsr - https://github.com/xinntao/BasicSR22 # We use BasicSR for both training and inference23 pip install basicsr24 25 # Install facexlib - https://github.com/xinntao/facexlib26 # We use face detection and face restoration helper in the facexlib package27 pip install facexlib28 29 pip install -r requirements.txt30 python setup.py develop31 32 # remember to set BASICSR_JIT=True before your running commands33 ```34 35 **Option 2: Compile extensions during installation** (For those need to train/inference for many times)36 37 ```bash38 # Install basicsr - https://github.com/xinntao/BasicSR39 # We use BasicSR for both training and inference40 # Set BASICSR_EXT=True to compile the cuda extensions in the BasicSR - It may take several minutes to compile, please be patient41 # Add -vvv for detailed log prints42 BASICSR_EXT=True pip install basicsr -vvv43 44 # Install facexlib - https://github.com/xinntao/facexlib45 # We use face detection and face restoration helper in the facexlib package46 pip install facexlib47 48 pip install -r requirements.txt49 python setup.py develop50 ```51 52## :zap: Quick Inference53 54Download pre-trained models: [GFPGANv1.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth)55 56```bash57wget https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth -P experiments/pretrained_models58```59 60- Option 1: Load extensions just-in-time(JIT)61 62 ```bash63 BASICSR_JIT=True python inference_gfpgan.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs --save_root results --arch original --channel 164 65 # for aligned images66 BASICSR_JIT=True python inference_gfpgan.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --save_root results --arch original --channel 1 --aligned67 ```68 69- Option 2: Have successfully compiled extensions during installation70 71 ```bash72 python inference_gfpgan.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs --save_root results --arch original --channel 173 74 # for aligned images75 python inference_gfpgan.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --save_root results --arch original --channel 1 --aligned76 ```77 