• Stars
    star
    34,212
  • Rank 442 (Top 0.01 %)
  • Language
    Python
  • License
    Other
  • Created about 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration.

download PyPI Open issue Closed issue LICENSE python lint Publish-pip

  1. ๐Ÿ’ฅ Updated online demo: Replicate. Here is the backup.
  2. ๐Ÿ’ฅ Updated online demo: Huggingface Gradio
  3. Colab Demo for GFPGAN google colab logo; (Another Colab Demo for the original paper model)

๐Ÿš€ Thanks for your interest in our work. You may also want to check our new updates on the tiny models for anime images and videos in Real-ESRGAN ๐Ÿ˜Š

GFPGAN aims at developing a Practical Algorithm for Real-world Face Restoration.
It leverages rich and diverse priors encapsulated in a pretrained face GAN (e.g., StyleGAN2) for blind face restoration.

โ“ Frequently Asked Questions can be found in FAQ.md.

๐Ÿšฉ Updates

  • โœ… Add RestoreFormer inference codes.
  • โœ… Add V1.4 model, which produces slightly more details and better identity than V1.3.
  • โœ… Add V1.3 model, which produces more natural restoration results, and better results on very low-quality / high-quality inputs. See more in Model zoo, Comparisons.md
  • โœ… Integrated to Huggingface Spaces with Gradio. See Gradio Web Demo.
  • โœ… Support enhancing non-face regions (background) with Real-ESRGAN.
  • โœ… We provide a clean version of GFPGAN, which does not require CUDA extensions.
  • โœ… We provide an updated model without colorizing faces.

If GFPGAN is helpful in your photos/projects, please help to โญ this repo or recommend it to your friends. Thanks๐Ÿ˜Š Other recommended projects:
โ–ถ๏ธ Real-ESRGAN: A practical algorithm for general image restoration
โ–ถ๏ธ BasicSR: An open-source image and video restoration toolbox
โ–ถ๏ธ facexlib: A collection that provides useful face-relation functions
โ–ถ๏ธ HandyView: A PyQt5-based image viewer that is handy for view and comparison


๐Ÿ“– GFP-GAN: Towards Real-World Blind Face Restoration with Generative Facial Prior

[Paper] โ€ƒ [Project Page] โ€ƒ [Demo]
Xintao Wang, Yu Li, Honglun Zhang, Ying Shan
Applied Research Center (ARC), Tencent PCG


๐Ÿ”ง Dependencies and Installation

Installation

We now provide a clean version of GFPGAN, which does not require customized CUDA extensions.
If you want to use the original model in our paper, please see PaperModel.md for installation.

  1. Clone repo

    git clone https://github.com/TencentARC/GFPGAN.git
    cd GFPGAN
  2. Install dependent packages

    # Install basicsr - https://github.com/xinntao/BasicSR
    # We use BasicSR for both training and inference
    pip install basicsr
    
    # Install facexlib - https://github.com/xinntao/facexlib
    # We use face detection and face restoration helper in the facexlib package
    pip install facexlib
    
    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

โšก Quick Inference

We take the v1.3 version for an example. More models can be found here.

Download pre-trained models: GFPGANv1.3.pth

wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models

Inference!

python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2
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/whole_imgs
  -o output            Output folder. Default: results
  -v version           GFPGAN model version. Option: 1 | 1.2 | 1.3. Default: 1.3
  -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

If you want to use the original model in our paper, please see PaperModel.md for installation and inference.

๐Ÿฐ Model Zoo

Version Model Name Description
V1.3 GFPGANv1.3.pth Based on V1.2; more natural restoration results; better results on very low-quality / high-quality inputs.
V1.2 GFPGANCleanv1-NoCE-C2.pth No colorization; no CUDA extensions are required. Trained with more data with pre-processing.
V1 GFPGANv1.pth The paper model, with colorization.

The comparisons are in Comparisons.md.

Note that V1.3 is not always better than V1.2. You may need to select different models based on your purpose and inputs.

Version Strengths Weaknesses
V1.3 โœ“ natural outputs
โœ“better results on very low-quality inputs
โœ“ work on relatively high-quality inputs
โœ“ can have repeated (twice) restorations
โœ— not very sharp
โœ— have a slight change on identity
V1.2 โœ“ sharper output
โœ“ with beauty makeup
โœ— some outputs are unnatural

You can find more models (such as the discriminators) here: [Google Drive], OR [Tencent Cloud ่…พ่ฎฏๅพฎไบ‘]

๐Ÿ’ป Training

We provide the training codes for GFPGAN (used in our paper).
You could improve it according to your own needs.

Tips

  1. More high quality faces can improve the restoration quality.
  2. You may need to perform some pre-processing, such as beauty makeup.

Procedures

(You can try a simple version ( options/train_gfpgan_v1_simple.yml) that does not require face component landmarks.)

  1. Dataset preparation: FFHQ

  2. Download pre-trained models and other data. Put them in the experiments/pretrained_models folder.

    1. Pre-trained StyleGAN2 model: StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth
    2. Component locations of FFHQ: FFHQ_eye_mouth_landmarks_512.pth
    3. A simple ArcFace model: arcface_resnet18.pth
  3. Modify the configuration file options/train_gfpgan_v1.yml accordingly.

  4. Training

python -m torch.distributed.launch --nproc_per_node=4 --master_port=22021 gfpgan/train.py -opt options/train_gfpgan_v1.yml --launcher pytorch

๐Ÿ“œ License and Acknowledgement

GFPGAN is released under Apache License Version 2.0.

BibTeX

@InProceedings{wang2021gfpgan,
    author = {Xintao Wang and Yu Li and Honglun Zhang and Ying Shan},
    title = {Towards Real-World Blind Face Restoration with Generative Facial Prior},
    booktitle={The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
    year = {2021}
}

๐Ÿ“ง Contact

If you have any question, please email [email protected] or [email protected].

More Repositories

1

PhotoMaker

PhotoMaker
Jupyter Notebook
7,753
star
2

T2I-Adapter

T2I-Adapter
Python
2,985
star
3

MotionCtrl

MotionCtrl: A Unified and Flexible Motion Controller for Video Generation
Python
981
star
4

MasaCtrl

[ICCV 2023] Consistent Image Synthesis and Editing
Python
636
star
5

Mix-of-Show

NeurIPS 2023, Mix-of-Show: Decentralized Low-Rank Adaptation for Multi-Concept Customization of Diffusion Models
Python
359
star
6

LLaMA-Pro

Progressive LLaMA with Block Expansion.
Python
335
star
7

AnimeSR

Codes for "AnimeSR: Learning Real-World Super-Resolution Models for Animation Videos"
Python
303
star
8

VQFR

ECCV 2022, Oral, VQFR: Blind Face Restoration with Vector-Quantized Dictionary and Parallel Decoder
Python
301
star
9

UMT

UMT is a unified and flexible framework which can handle different input modality combinations, and output video moment retrieval and/or highlight detection results.
Python
169
star
10

CustomNet

143
star
11

MM-RealSR

Codes for "Metric Learning based Interactive Modulation for Real-World Super-Resolution"
Python
139
star
12

MCQ

Official code for "Bridging Video-text Retrieval with Multiple Choice Questions", CVPR 2022 (Oral).
Python
126
star
13

FAIG

NeurIPS 2021, Spotlight, Finding Discriminative Filters for Specific Degradations in Blind Super-Resolution
Python
115
star
14

ViT-Lens

[CVPR 2024] ViT-Lens: Towards Omni-modal Representations
Python
111
star
15

DeSRA

Official codes for DeSRA (ICML 2023)
Python
109
star
16

ArcNerf

Nerf and extensions in all
Jupyter Notebook
105
star
17

RepSR

Codes for "RepSR: Training Efficient VGG-style Super-Resolution Networks with Structural Re-Parameterization and Batch Normalization"
73
star
18

SmartEdit

Official code of SmartEdit [CVPR-2024]
HTML
73
star
19

SurfelNeRF

SurfelNeRF: Neural Surfel Radiance Fields for Online Photorealistic Reconstruction of Indoor Scenes
72
star
20

FastRealVSR

Codes for "Mitigating Artifacts in Real-World Video Super-Resolution Models"
58
star
21

HOSNeRF

HOSNeRF: Dynamic Human-Object-Scene Neural Radiance Fields from a Single Video
Python
58
star
22

ConMIM

Official codes for ConMIM (ICLR 2023)
Python
52
star
23

GVT

Official code for "What Makes for Good Visual Tokenizers for Large Language Models?".
Python
47
star
24

TVTS

Turning to Video for Transcript Sorting
Jupyter Notebook
43
star
25

BEBR

Official code for "Binary embedding based retrieval at Tencent"
Python
41
star
26

FLM

Accelerating Vision-Language Pretraining with Free Language Modeling (CVPR 2023)
Python
30
star
27

Efficient-VSR-Training

Codes for "Accelerating the Training of Video Super-Resolution"
30
star
28

pi-Tuning

Official code for "pi-Tuning: Transferring Multimodal Foundation Models with Optimal Multi-task Interpolation", ICML 2023.
Python
29
star
29

ViSFT

Python
27
star
30

DTN

Official code for "Dynamic Token Normalization Improves Vision Transformer", ICLR 2022.
Python
27
star
31

OpenCompatible

OpenCompatible provides a standard compatible training benchmark, covering practical training scenarios.
Python
23
star
32

BTS

BTS: A Bi-lingual Benchmark for Text Segmentation in the Wild
20
star
33

SFDA

Python
18
star
34

SGAT4PASS

This is the official implementation of the paper SGAT4PASS: Spherical Geometry-Aware Transformer for PAnoramic Semantic Segmentation (IJCAI 2023)
Python
17
star
35

TaCA

Official code for the paper, "TaCA: Upgrading Your Visual Foundation Model with Task-agnostic Compatible Adapter".
14
star
36

common_trainer

Common template for pytorch project. Easy to extent and modify for new project.
Python
12
star
37

TransFusion

The code repo for the ACM MM paper: TransFusion: Multi-Modal Fusion for Video Tag Inference viaTranslation-based Knowledge Embedding.
9
star
38

BasicVQ-GEN

7
star
39

InstantMesh

InstantMesh: Efficient 3D Mesh Generation from a Single Image with Sparse-view Large Reconstruction Models
7
star
40

ArcVis

Visualization of 3d and 2d components interactively.
Jupyter Notebook
6
star
41

VTLayout

3
star