55[ ![ LICENSE] ( https://img.shields.io/badge/License-Apache%202.0-blue.svg )] ( https://github.com/TencentARC/GFPGAN/blob/master/LICENSE )
66[ ![ python lint] ( https://github.com/TencentARC/GFPGAN/actions/workflows/pylint.yml/badge.svg )] ( https://github.com/TencentARC/GFPGAN/blob/master/.github/workflows/pylint.yml )
77
8- [ ** Paper** ] ( https://arxiv.org/abs/2101.04061 ) ** |** [ ** Project Page** ] ( https://xinntao.github.io/projects/gfpgan ) &emsp ;&emsp ; [ English] ( README.md ) ** |** [ 简体中文] ( README_CN.md )
8+ 1 . [ Colab Demo] ( https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo ) for GFPGAN <a href =" https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo " ><img src =" https://colab.research.google.com/assets/colab-badge.svg " alt =" google colab logo " ></a >
9+ 1 . We provide a * clean* version of GFPGAN, which can run without CUDA extensions. So that it can run in ** Windows** or on ** CPU mode** .
910
10- GFPGAN is a blind face restoration algorithm towards real-world face images.
11+ GFPGAN aims at developing ** Practical Algorithm for Real-world Face Restoration** .<br >
12+ It leverages rich and diverse priors encapsulated in a pretrained face GAN (* e.g.* , StyleGAN2) for blind face restoration.
1113
12- <a href =" https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo " ><img src =" https://colab.research.google.com/assets/colab-badge.svg " alt =" google colab logo " ></a >
13- [ Colab Demo] ( https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo )
14+ :triangular_flag_on_post : ** Updates**
15+
16+ - :white_check_mark : We provide a * clean* version of GFPGAN, which does not require CUDA extensionts.
17+ - :white_check_mark : We provide an updated model without colorizing faces.
1418
1519### :book : GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior
20+
1621> [[ Paper] ( https://arxiv.org/abs/2101.04061 )] &emsp ; [[ Project Page] ( https://xinntao.github.io/projects/gfpgan )] &emsp ; [ Demo] <br >
1722> [ Xintao Wang] ( https://xinntao.github.io/ ) , [ Yu Li] ( https://yu-li.github.io/ ) , [ Honglun Zhang] ( https://scholar.google.com/citations?hl=en&user=KjQLROoAAAAJ ) , [ Ying Shan] ( https://scholar.google.com/citations?user=4oXBp9UAAAAJ&hl=en ) <br >
1823> Applied Research Center (ARC), Tencent PCG
1924
20- #### Abstract
21-
22- Blind face restoration usually relies on facial priors, such as facial geometry prior or reference prior, to restore realistic and faithful details. However, very low-quality inputs cannot offer accurate geometric prior while high-quality references are inaccessible, limiting the applicability in real-world scenarios. In this work, we propose GFP-GAN that leverages **rich and diverse priors encapsulated in a pretrained face GAN** for blind face restoration. This Generative Facial Prior (GFP) is incorporated into the face restoration process via novel channel-split spatial feature transform layers, which allow our method to achieve a good balance of realness and fidelity. Thanks to the powerful generative facial prior and delicate designs, our GFP-GAN could jointly restore facial details and enhance colors with just a single forward pass, while GAN inversion methods require expensive image-specific optimization at inference. Extensive experiments show that our method achieves superior performance to prior art on both synthetic and real-world datasets.
23-
24- #### BibTeX
25-
26- @InProceedings{wang2021gfpgan,
27- author = {Xintao Wang and Yu Li and Honglun Zhang and Ying Shan},
28- title = {Towards Real-World Blind Face Restoration with Generative Facial Prior},
29- booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
30- year = {2021}
31- }
32-
3325<p align =" center " >
3426 <img src =" https://xinntao.github.io/projects/GFPGAN_src/gfpgan_teaser.jpg " >
3527</p >
@@ -40,25 +32,23 @@ Blind face restoration usually relies on facial priors, such as facial geometry
4032
4133- Python >= 3.7 (Recommend to use [ Anaconda] ( https://www.anaconda.com/download/#linux ) or [ Miniconda] ( https://docs.conda.io/en/latest/miniconda.html ) )
4234- [ PyTorch >= 1.7] ( https://pytorch.org/ )
43- - NVIDIA GPU + [ CUDA] ( https://developer.nvidia.com/cuda-downloads )
44- - Linux (We have not tested on Windows)
35+ - Option: NVIDIA GPU + [ CUDA] ( https://developer.nvidia.com/cuda-downloads )
36+ - Option: Linux (We have not tested on Windows)
4537
4638### Installation
4739
40+ We now provide a * clean* version of GFPGAN, which does not require customized CUDA extensions. <br >
41+ If you want want to use the original model in our paper, please see [ PaperModel.md] ( PaperModel.md ) for installation.
42+
48431 . Clone repo
4944
5045 ``` bash
51- git clone https://github.com/xinntao /GFPGAN.git
46+ git clone https://github.com/TencentARC /GFPGAN.git
5247 cd GFPGAN
5348 ```
5449
55501. Install dependent packages
5651
57- As StyleGAN2 uses customized PyTorch C++ extensions, you need to ** compile them during installation** or ** load then just-in-time(JIT)** .
58- You can refer to [BasicSR-INSTALL.md](https://github.com/xinntao/BasicSR/blob/master/INSTALL.md) for more details.
59-
60- ** Option 1: Load extensions just-in-time(JIT)** (For those just want to do simple inferences, may have less issues)
61-
6252 ` ` ` bash
6353 # Install basicsr - https://github.com/xinntao/BasicSR
6454 # We use BasicSR for both training and inference
@@ -69,56 +59,41 @@ Blind face restoration usually relies on facial priors, such as facial geometry
6959 pip install facexlib
7060
7161 pip install -r requirements.txt
72-
73- # remember to set BASICSR_JIT=True before your running commands
7462 ` ` `
7563
76- ** Option 2: Compile extensions during installation** (For those need to train/inference for many times)
77-
78- ` ` ` bash
79- # Install basicsr - https://github.com/xinntao/BasicSR
80- # We use BasicSR for both training and inference
81- # Set BASICSR_EXT=True to compile the cuda extensions in the BasicSR - It may take several minutes to compile, please be patient
82- # Add -vvv for detailed log prints
83- BASICSR_EXT=True pip install basicsr -vvv
84-
85- # Install facexlib - https://github.com/xinntao/facexlib
86- # We use face detection and face restoration helper in the facexlib package
87- pip install facexlib
64+ # # :zap: Quick Inference
8865
89- pip install -r requirements.txt
90- ` ` `
66+ Download pre-trained models: [GFPGANCleanv1-NoCE-C2.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth)
9167
92- # # :zap: Quick Inference
68+ ` ` ` bash
69+ wget https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth -P experiments/pretrained_models
70+ ` ` `
9371
94- Download pre-trained models: [GFPGANv1.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth)
72+ ** Inference ! **
9573
9674` ` ` bash
97- wget https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth -P experiments/pretrained_models
75+ python inference_gfpgan_full.py --upscale_factor 2 --test_path inputs/whole_imgs --save_root results
9876` ` `
9977
100- - Option 1: Load extensions just-in-time(JIT)
78+ # # :european_castle: Model Zoo
10179
102- ` ` ` bash
103- BASICSR_JIT=True python inference_gfpgan_full.py --model_path experiments/pretrained_models/ GFPGANv1.pth --test_path inputs/whole_imgs
80+ - [GFPGANCleanv1-NoCE-C2.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth)
81+ - [GFPGANv1.pth](https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/ GFPGANv1.pth)
10482
105- # for aligned images
106- BASICSR_JIT=True python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned
107- ` ` `
83+ # # :computer: Training
10884
109- - Option 2: Have successfully compiled extensions during installation
85+ We provide the training codes for GFPGAN (used in our paper). < br>
86+ You could improve it according to your own needs.
11087
111- ` ` ` bash
112- python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs
88+ ** Tips**
11389
114- # for aligned images
115- python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned
116- ` ` `
90+ 1. More high quality faces can improve the restoration quality.
91+ 2. You may need to perform some pre-processing, such as beauty makeup.
11792
118- # # :computer: Training
11993
120- We provide complete training codes for GFPGAN. < br>
121- You could improve it according to your own needs.
94+ ** Procedures**
95+
96+ (You can try a simple version ( ` train_gfpgan_v1_simple.yml` ) that does not require face component landmarks.)
12297
123981. Dataset preparation: [FFHQ](https://github.com/NVlabs/ffhq-dataset)
12499
@@ -133,13 +108,18 @@ You could improve it according to your own needs.
133108
134109> python -m torch.distributed.launch --nproc_per_node=4 --master_port=22021 train.py -opt train_gfpgan_v1.yml --launcher pytorch
135110
136- or load extensions just-in-time(JIT)
111+ # # :scroll: License and Acknowledgement
137112
138- > BASICSR_JIT=True python -m torch.distributed.launch --nproc_per_node=4 --master_port=22021 train.py -opt train_gfpgan_v1.yml --launcher pytorch
113+ GFPGAN is released under Apache License Version 2.0.
139114
140- # # :scroll: License and Acknowledgement
115+ # # BibTeX
141116
142- GFPGAN is realeased under Apache License Version 2.0.
117+ @InProceedings{wang2021gfpgan,
118+ author = {Xintao Wang and Yu Li and Honglun Zhang and Ying Shan},
119+ title = {Towards Real-World Blind Face Restoration with Generative Facial Prior},
120+ booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
121+ year = {2021}
122+ }
143123
144124# # :e-mail: Contact
145125
0 commit comments