GFPGAN is a blind face restoration algorithm towards real-world face images.

Related tags

Admin Panels GFPGAN
Overview

GFPGAN (CVPR 2021)

Paper | Project Page    English | 简体中文

GFPGAN is a blind face restoration algorithm towards real-world face images.

google colab logo Colab Demo

📖 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

Abstract

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.

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}
}


🔧 Dependencies and Installation

Installation

  1. Clone repo

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

    # Install basicsr - https://github.com/xinntao/BasicSR
    # We use BasicSR for both training and inference
    # Set BASICSR_EXT=True to compile the cuda extensions in the BasicSR - It may take several minutes to compile, please be patient
    BASICSR_EXT=True 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

Quick Inference

Download pre-trained models: GFPGANv1.pth

wget https://github.com/TencentARC/GFPGAN/releases/download/v0.1.0/GFPGANv1.pth -P experiments/pretrained_models
python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs

# for aligned images
python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned

💻 Training

We provide complete training codes for GFPGAN.
You could improve it according to your own needs.

  1. Dataset preparation: FFHQ

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

    1. Pretrained 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 train_gfpgan_v1.yml accordingly.

  4. Training

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

📜 License and Acknowledgement

GFPGAN is realeased under Apache License Version 2.0.

📧 Contact

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

Comments
  • 训练日志异常

    训练日志异常

    为什么当我将4gpu调整为2gpu,训练时就不输出结果?无论是实时终端,亦或是experiments内项目文件下本应出现的log文件,都无。改动如下:

    # general settings
    name: train_GFPGANv1_512_2gpu
    model_type: GFPGANModel
    num_gpu: 2     # 4
    manual_seed: 0
    

    2021-07-06 10-33-58 的屏幕截图 gpu看情况是进入训练状态的。 ps:之前复现您的BasicSR中的esrgan也是类似情况

    opened by JiaweiShiCV 28
  • ImportError: No module named 'deform_conv'

    ImportError: No module named 'deform_conv'

    I run Quick Inference after I finish the installation: "python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned". Then I encountered the following error:

    `(GFPGAN) D:\Profession\Git\GFPGAN>python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/cropped_faces --aligned ----compiler_info: 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版 版权所有(C) Microsoft Corporation。保留所有权利。

    用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]

    ----match: <re.Match object; span=(35, 46), match='19.16.27045'> Traceback (most recent call last): File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn\deform_conv.py", line 10, in from . import deform_conv_ext ImportError: cannot import name 'deform_conv_ext' from 'basicsr.ops.dcn' (D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn_init_.py)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "inference_gfpgan_full.py", line 10, in from archs.gfpganv1_arch import GFPGANv1 File "D:\Profession\Git\GFPGAN\archs_init_.py", line 4, in from basicsr.utils import scandir File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr_init_.py", line 3, in from .archs import * File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs_init_.py", line 16, in arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames] File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs_init.py", line 16, in arch_modules = [importlib.import_module(f'basicsr.archs.{file_name}') for file_name in arch_filenames] File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\importlib_init.py", line 127, in import_module return _bootstrap.gcd_import(name[level:], package, level) File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs\edsr_arch.py", line 4, in from basicsr.archs.arch_util import ResidualBlockNoBN, Upsample, make_layer File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\archs\arch_util.py", line 8, in from basicsr.ops.dcn import ModulatedDeformConvPack, modulated_deform_conv File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn_init.py", line 1, in from .deform_conv import (DeformConv, DeformConvPack, ModulatedDeformConv, ModulatedDeformConvPack, deform_conv, File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\basicsr\ops\dcn\deform_conv.py", line 22, in os.path.join(module_path, 'src', 'deform_conv_cuda_kernel.cu'), File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 983, in load keep_intermediates=keep_intermediates) File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 1199, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\site-packages\torch\utils\cpp_extension.py", line 1546, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "D:\Profession\ProgramData\Anaconda3\envs\GFPGAN\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'deform_conv'`

    I found that someone had the same problem as me, but it didn’t solve it. Is there a solution to this ERROR?Thanks for the ANY HELP~

    opened by EndeCC0 16
  • NameError: name 'fused_act_ext' is not defined

    NameError: name 'fused_act_ext' is not defined

    Attempt for quick inference is throwing NameError: name 'fused_act_ext' is not defined. I'll highly appreciate your assistance. Below are the details of the error and conda packages.

    Your assistance can also come in a form of simply sharing your list installed packages.

    $ python inference_gfpgan_full.py --model_path experiments/pretrained_models/GFPGANv1.pth --test_path inputs/whole_imgs
    Processing 00.jpg ...
    Traceback (most recent call last):
    File "/deepmind/github/tencentarc/gfpgan/inference_gfpgan_full.py", line 120, in <module>
    restoration(
    File "/deepmind/github/tencentarc/gfpgan/inference_gfpgan_full.py", line 49, in restoration
    output = gfpgan(cropped_face_t, return_rgb=False)[0]
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
    File "/deepmind/github/tencentarc/gfpgan/archs/gfpganv1_arch.py", line 348, in forward
    feat = self.conv_body_first(x)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/basicsr/ops/fused_act/fused_act.py", line 85, in forward
    return fused_leaky_relu(input, self.bias, self.negative_slope, self.scale)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/basicsr/ops/fused_act/fused_act.py", line 89, in fused_leaky_relu
    return FusedLeakyReLUFunction.apply(input, bias, negative_slope, scale)
    File "/storage/usr/conda/envs/gfpgan/lib/python3.9/site-packages/basicsr/ops/fused_act/fused_act.py", line 59, in forward
    out = fused_act_ext.fused_bias_act(input, bias, empty, 3, 0, negative_slope, scale)
    NameError: name 'fused_act_ext' is not defined
    
    $ conda list
    # packages in environment at /storage/usr/conda/envs/gfpgan:
    #
    # Name                    Version                   Build  Channel
    _libgcc_mutex             0.1                 conda_forge    conda-forge
    _openmp_mutex             4.5                      1_llvm    conda-forge
    _pytorch_select           0.1                       cpu_0    anaconda
    absl-py                   0.13.0             pyhd8ed1ab_0    conda-forge
    addict                    2.4.0            py39hf3d152e_0    conda-forge
    aiohttp                   3.7.4.post0      py39h3811e60_0    conda-forge
    alsa-lib                  1.2.3                h516909a_0    conda-forge
    appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
    async-timeout             3.0.1                   py_1000    conda-forge
    attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
    basicsr                   1.3.3.4                  pypi_0    pypi
    blas                      1.0                         mkl    anaconda
    blinker                   1.4                        py_1    conda-forge
    blosc                     1.21.0               h9c3ff4c_0    conda-forge
    brotli                    1.0.9                h9c3ff4c_4    conda-forge
    brotlipy                  0.7.0           py39h3811e60_1001    conda-forge
    brunsli                   0.1                  h9c3ff4c_0    conda-forge
    bzip2                     1.0.8                h7f98852_4    conda-forge
    c-ares                    1.17.1               h7f98852_1    conda-forge
    ca-certificates           2021.5.30            ha878542_0    conda-forge
    cachetools                4.2.2              pyhd8ed1ab_0    conda-forge
    cairo                     1.16.0            h6cf1ce9_1008    conda-forge
    certifi                   2021.5.30        py39hf3d152e_0    conda-forge
    cffi                      1.14.5           py39he32792d_0    conda-forge
    cfitsio                   3.470                hb418390_7    conda-forge
    chardet                   4.0.0            py39hf3d152e_1    conda-forge
    charls                    2.2.0                h9c3ff4c_0    conda-forge
    click                     8.0.1            py39hf3d152e_0    conda-forge
    cloudpickle               1.6.0                      py_0    conda-forge
    cryptography              3.4.7            py39hbca0aa6_0    conda-forge
    cudatoolkit               10.2.89              h8f6ccaa_8    conda-forge
    cycler                    0.10.0                     py_2    conda-forge
    cytoolz                   0.11.0           py39h3811e60_3    conda-forge
    dask-core                 2021.6.1           pyhd8ed1ab_0    conda-forge
    dataclasses               0.8                pyhc8e2a94_1    conda-forge
    dbus                      1.13.18              hb2f20db_0    anaconda
    decorator                 5.0.9              pyhd8ed1ab_0    conda-forge
    expat                     2.4.1                h9c3ff4c_0    conda-forge
    facexlib                  0.1.3                    pypi_0    pypi
    ffmpeg                    4.3.1                hca11adc_2    conda-forge
    fontconfig                2.13.1            hba837de_1005    conda-forge
    freetype                  2.10.4               h0708190_1    conda-forge
    fsspec                    2021.6.0           pyhd8ed1ab_0    conda-forge
    future                    0.18.2           py39hf3d152e_3    conda-forge
    gettext                   0.21.0               hf68c758_0  
    giflib                    5.2.1                h36c2ea0_2    conda-forge
    glib                      2.68.3               h9c3ff4c_0    conda-forge
    glib-tools                2.68.3               h9c3ff4c_0    conda-forge
    gmp                       6.2.1                h58526e2_0    conda-forge
    gnutls                    3.6.15               he1e5248_0  
    google-auth               1.31.0             pyhd3eb1b0_0  
    google-auth-oauthlib      0.4.1                      py_2    conda-forge
    graphite2                 1.3.14               h23475e2_0    anaconda
    grpcio                    1.38.0           py39hff7568b_0    conda-forge
    gst-plugins-base          1.18.4               hf529b03_2    conda-forge
    gstreamer                 1.18.4               h76c114f_2    conda-forge
    harfbuzz                  2.8.1                h83ec7ef_0    conda-forge
    hdf5                      1.10.6          nompi_h6a2412b_1114    conda-forge
    icu                       68.1                 h58526e2_0    conda-forge
    idna                      2.10               pyh9f0ad1d_0    conda-forge
    imagecodecs               2021.6.8         py39h44211f0_0    conda-forge
    imageio                   2.9.0                      py_0    conda-forge
    importlib-metadata        4.5.0            py39hf3d152e_0    conda-forge
    jasper                    1.900.1           h07fcdf6_1006    conda-forge
    jbig                      2.1               h7f98852_2003    conda-forge
    jpeg                      9d                   h36c2ea0_0    conda-forge
    jxrlib                    1.1                  h7f98852_2    conda-forge
    kiwisolver                1.3.1            py39h1a9c180_1    conda-forge
    krb5                      1.19.1               hcc1bbae_0    conda-forge
    lame                      3.100             h7f98852_1001    conda-forge
    lcms2                     2.12                 hddcbb42_0    conda-forge
    ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
    lerc                      2.2.1                h9c3ff4c_0    conda-forge
    libaec                    1.0.5                h9c3ff4c_0    conda-forge
    libblas                   3.9.0                     8_mkl    conda-forge
    libcblas                  3.9.0                     8_mkl    conda-forge
    libclang                  11.1.0          default_ha53f305_1    conda-forge
    libcurl                   7.77.0               h2574ce0_0    conda-forge
    libdeflate                1.7                  h7f98852_5    conda-forge
    libedit                   3.1.20210216         h27cfd23_1  
    libev                     4.33                 h516909a_1    conda-forge
    libevent                  2.1.10               hcdb4288_3    conda-forge
    libffi                    3.3                  h58526e2_2    conda-forge
    libgcc-ng                 9.3.0               h2828fa1_19    conda-forge
    libgfortran-ng            9.3.0               hff62375_19    conda-forge
    libgfortran5              9.3.0               hff62375_19    conda-forge
    libglib                   2.68.3               h3e27bee_0    conda-forge
    libiconv                  1.16                 h516909a_0    conda-forge
    libidn2                   2.3.1                h7f98852_0    conda-forge
    liblapack                 3.9.0                     8_mkl    conda-forge
    liblapacke                3.9.0                     8_mkl    conda-forge
    libllvm11                 11.1.0               hf817b99_2    conda-forge
    libnghttp2                1.43.0               h812cca2_0    conda-forge
    libogg                    1.3.5                h27cfd23_1  
    libopencv                 4.5.2            py39h2406f9b_0    conda-forge
    libopus                   1.3.1                h7f98852_1    conda-forge
    libpng                    1.6.37               h21135ba_2    conda-forge
    libpq                     13.3                 hd57d9b9_0    conda-forge
    libprotobuf               3.15.8               h780b84a_0    conda-forge
    libssh2                   1.9.0                ha56f1ee_6    conda-forge
    libstdcxx-ng              9.3.0               h6de172a_19    conda-forge
    libtasn1                  4.16.0               h27cfd23_0  
    libtiff                   4.3.0                hf544144_1    conda-forge
    libunistring              0.9.10               h14c3975_0    conda-forge
    libuuid                   2.32.1            h7f98852_1000    conda-forge
    libuv                     1.41.0               h7f98852_0    conda-forge
    libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
    libwebp-base              1.2.0                h7f98852_2    conda-forge
    libxcb                    1.14                 h7b6447c_0    anaconda
    libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
    libxml2                   2.9.12               h72842e0_0    conda-forge
    libzopfli                 1.0.3                h9c3ff4c_0    conda-forge
    llvm-openmp               11.1.0               h4bd325d_1    conda-forge
    lmdb                      1.2.1                    pypi_0    pypi
    locket                    0.2.1            py39h06a4308_1  
    lz4-c                     1.9.3                h9c3ff4c_0    conda-forge
    markdown                  3.3.4              pyhd8ed1ab_0    conda-forge
    matplotlib-base           3.4.2            py39h2fa2bec_0    conda-forge
    mkl                       2020.4             h726a3e6_304    conda-forge
    multidict                 5.1.0            py39h3811e60_1    conda-forge
    mysql-common              8.0.25               ha770c72_2    conda-forge
    mysql-libs                8.0.25               hfa10184_2    conda-forge
    ncurses                   6.2                  h58526e2_4    conda-forge
    nettle                    3.7.3                hbbd107a_1  
    networkx                  2.5                        py_0    anaconda
    ninja                     1.10.2               h4bd325d_0    conda-forge
    nspr                      4.30                 h9c3ff4c_0    conda-forge
    nss                       3.67                 hb5efdd6_0    conda-forge
    numpy                     1.20.3           py39hdbf815f_1    conda-forge
    oauthlib                  3.1.1              pyhd8ed1ab_0    conda-forge
    olefile                   0.46               pyh9f0ad1d_1    conda-forge
    opencv                    4.5.2            py39hf3d152e_0    conda-forge
    opencv-python             4.5.2.54                 pypi_0    pypi
    openh264                  2.1.1                h780b84a_0    conda-forge
    openjpeg                  2.4.0                hb52868f_1    conda-forge
    openssl                   1.1.1k               h7f98852_0    conda-forge
    packaging                 20.9               pyh44b312d_0    conda-forge
    partd                     1.2.0              pyhd8ed1ab_0    conda-forge
    pcre                      8.45                 h9c3ff4c_0    conda-forge
    pillow                    8.2.0            py39hf95b381_1    conda-forge
    pip                       21.1.2             pyhd8ed1ab_0    conda-forge
    pixman                    0.40.0               h36c2ea0_0    conda-forge
    pooch                     1.4.0              pyhd8ed1ab_0    conda-forge
    protobuf                  3.15.8           py39he80948d_0    conda-forge
    py-opencv                 4.5.2            py39hef51801_0    conda-forge
    pyasn1                    0.4.8                      py_0    conda-forge
    pyasn1-modules            0.2.8                      py_0    anaconda
    pycparser                 2.20               pyh9f0ad1d_2    conda-forge
    pyjwt                     2.1.0              pyhd8ed1ab_0    conda-forge
    pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
    pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
    pysocks                   1.7.1            py39hf3d152e_3    conda-forge
    python                    3.9.5           h49503c6_0_cpython    conda-forge
    python-dateutil           2.8.1                      py_0    conda-forge
    python_abi                3.9                      1_cp39    conda-forge
    pytorch                   1.7.1           py3.9_cuda10.2.89_cudnn7.6.5_0    pytorch
    pywavelets                1.1.1            py39hce5d2b2_3    conda-forge
    pyyaml                    5.4.1            py39h3811e60_0    conda-forge
    qt                        5.12.9               hda022c4_4    conda-forge
    readline                  8.1                  h46c0cb4_0    conda-forge
    requests                  2.25.1             pyhd3deb0d_0    conda-forge
    requests-oauthlib         1.3.0              pyh9f0ad1d_0    conda-forge
    rsa                       4.7.2              pyh44b312d_0    conda-forge
    scikit-image              0.18.1           py39hde0f152_0    conda-forge
    scipy                     1.6.3            py39hee8e79c_0    conda-forge
    setuptools                52.0.0           py39h06a4308_0  
    six                       1.16.0             pyh6c4a22f_0    conda-forge
    sleef                     3.5.1                h7f98852_1    conda-forge
    snappy                    1.1.8                he1b5a44_3    conda-forge
    sqlite                    3.35.5               h74cdb3f_0    conda-forge
    tb-nightly                2.6.0a20210615           pypi_0    pypi
    tensorboard               2.5.0              pyhd8ed1ab_0    conda-forge
    tensorboard-data-server   0.6.0            py39h3da14fd_0    conda-forge
    tensorboard-plugin-wit    1.8.0              pyh44b312d_0    conda-forge
    tifffile                  2021.6.14          pyhd8ed1ab_0    conda-forge
    tk                        8.6.10               h21135ba_1    conda-forge
    toolz                     0.11.1                     py_0    conda-forge
    torchvision               0.8.2           cpu_py39ha229d99_0  
    tornado                   6.1              py39h3811e60_1    conda-forge
    tqdm                      4.61.1             pyhd8ed1ab_0    conda-forge
    typing-extensions         3.10.0.0             hd8ed1ab_0    conda-forge
    typing_extensions         3.10.0.0           pyha770c72_0    conda-forge
    tzdata                    2021a                he74cb21_0    conda-forge
    urllib3                   1.26.5             pyhd8ed1ab_0    conda-forge
    werkzeug                  2.0.1              pyhd8ed1ab_0    conda-forge
    wheel                     0.36.2             pyhd3deb0d_0    conda-forge
    x264                      1!161.3030           h7f98852_1    conda-forge
    xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
    xorg-libice               1.0.10               h7f98852_0    conda-forge
    xorg-libsm                1.2.3             hd9c2040_1000    conda-forge
    xorg-libx11               1.7.2                h7f98852_0    conda-forge
    xorg-libxext              1.3.4                h7f98852_1    conda-forge
    xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
    xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
    xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
    xorg-xproto               7.0.31            h7f98852_1007    conda-forge
    xz                        5.2.5                h516909a_1    conda-forge
    yaml                      0.2.5                h516909a_0    conda-forge
    yapf                      0.31.0             pyhd8ed1ab_0    conda-forge
    yarl                      1.6.3            py39h3811e60_1    conda-forge
    zfp                       0.5.5                h9c3ff4c_5    conda-forge
    zipp                      3.4.1              pyhd8ed1ab_0    conda-forge
    zlib                      1.2.11            h516909a_1010    conda-forge
    zstd                      1.5.0                ha95c52a_0    conda-forge
    
    opened by jerrymatjila 15
  • I want export

    I want export "GFPGANCleanv1-NoCE-C2.pth" to ONNX

    I want to use dynamic weights in F.conv2d in pytorch.

        def forward(self, x, style):
            b, c, h, w = x.shape  # c = c_in
    
            style = self.modulation(style).view(b, 1, c, 1, 1)
            weight = self.weight * style  # (b, c_out, c_in, k, k)
            weight = weight.view(b * self.out_channels, c, self.kernel_size, self.kernel_size)
    
            b, c, h, w = x.shape
            x = x.view(1, b * c, h, w)
    
            out = F.conv2d(x, weight, padding=self.padding, groups=b)
            out = out.view(b, self.out_channels, *out.shape[2:4])
    
            return out
    

    However, only constant weights are supported in Barracuda.

    How can I change F.conv2d?

    opened by jjeamin 11
  • Complile error when building extension 'deform_conv'

    Complile error when building extension 'deform_conv'

    I have followed the "Installation" but encountering below error. Details are attached below. Any help will be grateful. When running cmd: CUDA_HOME=/usr/local/cuda-10.2 BASICSR_EXT=True pip install basicsr below error shows: ERROR: Command errored out with exit status 1: command: /data/anaconda3/envs/pytorch18/bin/python3.8 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ekcq6eum/basicsr_4146e4815a4548d195157ceecc274ac0/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ekcq6eum/basicsr_4146e4815a4548d195157ceecc274ac0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-uoof9gcv cwd: /tmp/pip-install-ekcq6eum/basicsr_4146e4815a4548d195157ceecc274ac0/ Complete output (260 lines): Traceback (most recent call last): File "/tmp/pip-install-ekcq6eum/basicsr_4146e4815a4548d195157ceecc274ac0/basicsr/ops/dcn/deform_conv.py", line 10, in <module> from . import deform_conv_ext ImportError: cannot import name 'deform_conv_ext' from partially initialized module 'basicsr.ops.dcn' (most likely due to a circular import) (/tmp/pip-install-ekcq6eum/basicsr_4146e4815a4548d195157ceecc274ac0/basicsr/ops/dcn/__init__.py)

    The error shows we can't import deform_conv_ext. I think it says that module deform_conv_ext has not been built successfully. But i don't know how to check it when using pip install. So i try to install basicsr by git clone and compile following this link. But when i ran command: CUDA_HOME=/usr/local/cuda-10.2 BASICSR_EXT=True python setup.py develop It failed when building 'basicsr.ops.dcn.deform_conv_ext' extension image

    I have googled it and found no useful information. Here is my enviroment: gcc: 7.5.0 cuda: 10.2 image torch.config.show() 'PyTorch built with:\n - GCC 7.3\n - C++ Version: 201402\n

    opened by syfbme 11
  • Has colorization been removed or only disabled?

    Has colorization been removed or only disabled?

    Generative facial prior is genius. Wonderful research

    Was colorization removed or just disabled by feature? I was unable to locate color jitter or grey settings.

    opened by Ghee36 10
  • Add Docker environment & web demo

    Add Docker environment & web demo

    Hey @xinntao ! 👋

    Appreciated your feedback on the previous PR. It has been modified accordingly in this PR.

    This pull request makes it possible to run your model inside a Docker environment, which makes it easier for other people to run it. We're using an open source tool called Cog to make this process easier.

    This also means we can make a web page where other people can try out your model! View it here: https://replicate.ai/xinntao/gfpgan (We noticed that you have a demo on Gradio, but some of the example images, e.g. 10045.png, would show error there).

    Claim your page here so you can edit it, and we'll feature it on our website and tweet about it too.

    In case you're wondering who I am, I'm from Replicate, where we're trying to make machine learning reproducible. We got frustrated that we couldn't run all the really interesting ML work being done. So, we're going round implementing models we like. 😊

    opened by chenxwh 9
  • 你好大佬,请教几个环境问题

    你好大佬,请教几个环境问题

    大佬好,今天尝试运行这个项目,安装环境失败。 第一次尝试torch==1.9.0+cu111,提示CUDA driver initialization failed, you might not have a CUDA gpu 第二次尝试torch==1.7.0+cu10.2,提示The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. 之前运行DFDNET和GPEN都是没问题的,请问我这是哪里出问题了?希望百忙之中能抽时间帮忙解答下,感谢!

    opened by theoldsong 8
  • 使用checkpoint继续训练的bug

    使用checkpoint继续训练的bug

    当我想要从断点继续训练,我修改了.yml文件以下内容:

    # path
    path:
      pretrain_network_g: experiments/train_GFPGANv1_512/models/net_g_490000.pth
      param_key_g: params_ema
      strict_load_g: ~
      pretrain_network_d: experiments/train_GFPGANv1_512/models/net_d_490000.pth
      pretrain_network_d_left_eye: experiments/train_GFPGANv1_512/models/net_d_left_eye_490000.pth
      pretrain_network_d_right_eye: experiments/train_GFPGANv1_512/models/net_d_right_eye_490000.pth
      pretrain_network_d_mouth: experiments/train_GFPGANv1_512/models/net_d_mouth_490000.pth
      pretrain_network_identity: experiments/pretrained_models/arcface_resnet18.pth
      # resume
      resume_state: experiments/train_GFPGANv1_512/training_states/490000.state
      ignore_resume_networks: ['network_identity']
    

    我并没有修改pretrain_network_identity项。 但是随后报错:

    FileNotFoundError: [Errno 2] No such file or directory: 'GFPGAN/experiments/train_GFPGANv1_512/models/net_identity_490000.pth'
    

    一脸懵啊。。。 翻看log初始打印所有配置,此时pretrain_network_identity已经变了:

    2021-07-11 22:21:11,000 INFO: Loading ResNetArcFace model from GFPGAN/experiments/train_GFPGANv1_512/models/net_identity_490000.pth.
    

    这。。。。

    opened by JiaweiShiCV 8
  • results are strange while testing on whole img

    results are strange while testing on whole img

    Hi, I'm using pretrain model for testing, while testing on align cropped faces, the results are promising. However, while testing as whole img the results are wrong, seems the detection is not working well because in results cmp folder there is no faces or sereval faces in one img.

    I didn't change the code, is there anything wrong the whole img testing? Thanks in advance.

    opened by tachikoma777 7
  • only paste back from already restored faces

    only paste back from already restored faces

    Is it possible to do this without restoring faces again just with 2x esrgan?

    like

    "python inference_gfpgan.py --upscale 2 --model_path nomodel --test_path results/restored_faces --save_root results/restored_images --paste_back_only"

    ?

    opened by NoUserNameForYou 6
  • Cannot find ground truth images in lfw_cropped_faces, CelebChild-Test, and WebPhoto-Test dataset

    Cannot find ground truth images in lfw_cropped_faces, CelebChild-Test, and WebPhoto-Test dataset

    Hi @xinntao ,

    Thank you so much for your awesome work. Recently, I tried to follow this paper and show comparisons on datasets. However, I cannot find the ground-truth images in lfw_cropped_faces, CelebChild-Test, and WebPhoto-Test datasets. Could you give me some advice? Thanks!

    Best, Wanglong

    opened by LonglongaaaGo 0
  • Replicate and Huggingface Gradio Demos, different image download problem

    Replicate and Huggingface Gradio Demos, different image download problem

    After the face restoration is done in the demos, the image we download is a different image. Presumably, it's a picture uploaded by another person doing face restoration at the same time.

    opened by sezginibis 0
  • Can't Import basicsr

    Can't Import basicsr

    when I install basicsr on my serve,I found it will stuck when I import basicsr image and also,When i want to reinstall basicsr,I find i can't install it with this error image

    opened by yitianlian 0
  • Face identification box is too large, so the fixing function breaks hair and accessories

    Face identification box is too large, so the fixing function breaks hair and accessories

    Is there a way to adjust the face identification to focus only on eyes or really only inside the face?

    The current box is too large and breaks anything outside the face (hair accessory, earrings).

    00005-240035775-mdjrny-v4 style, portrait of a male cleric, D D, fantasy, intricate, elegant, highly detailed, digital painting, artstation, con_00

    Using a simpler but probably not generally accurate code we can find the eyes only.

    But it has been hard to then run the fixing function through it.

    localhost embedded

    Any way to make the face identification much tighter or focus only on eyes?

    Thanks!

    Simple code to identify only eyes.

    import facexlib
    import tensorflow as tf
    import cv2
    from google.colab.patches import cv2_imshow
    
    # Load the Haar cascade for detecting eyes
    eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
    
    # Read the image and convert it to grayscale
    image = cv2.imread('img.png')
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    
    # Adjust the scale factor and minimum neighbor count for the classifier
    scale_factor = 1.33
    min_neighbors = 18
    
    # Detect eyes in the image
    eyes = eye_cascade.detectMultiScale(gray, scale_factor, min_neighbors)
    
    # Draw a rectangle around the eyes
    for (x,y,w,h) in eyes:
        cv2.rectangle(image, (x,y), (x+w, y+h), (255,0,0), 2)
    
    # Show the image
    cv2_imshow(image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    
    opened by grexzen 1
Releases(v1.3.8)
Owner
Applied Research Center (ARC), Tencent PCG
Applied Research Center (ARC), Tencent PCG
Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data

Real-ESRGAN Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data Ported from https://github.com/xinntao/Real-ESRGAN Depend

Holy Wu 44 Dec 27, 2022
Code for Blind Image Decomposition (BID) and Blind Image Decomposition network (BIDeN).

arXiv, porject page, paper Blind Image Decomposition (BID) Blind Image Decomposition is a novel task. The task requires separating a superimposed imag

null 64 Dec 20, 2022
A python software that can help blind people find things like laptops, phones, etc the same way a guide dog guides a blind person in finding his way.

GuidEye A python software that can help blind people find things like laptops, phones, etc the same way a guide dog guides a blind person in finding h

Munal Jain 0 Aug 9, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 3, 2023
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 1, 2023
Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021)

Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021)

Jiaxi Jiang 282 Jan 2, 2023
Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021)

Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021) Jiaxi Jiang, Kai Zhang, Radu Timofte Computer Vision Lab, ETH Zurich, Switzerland ??

Jiaxi Jiang 80 Sep 30, 2021
Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration.

Real-ESRGAN Colab Demo for Real-ESRGAN . Portable Windows executable file. You can find more information here. Real-ESRGAN aims at developing Practica

Xintao 17.2k Jan 2, 2023
Official repository for "Restormer: Efficient Transformer for High-Resolution Image Restoration". SOTA for motion deblurring, image deraining, denoising (Gaussian/real data), and defocus deblurring.

Restormer: Efficient Transformer for High-Resolution Image Restoration Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan,

Syed Waqas Zamir 906 Dec 30, 2022
The project's goal is to show a real world application of image segmentation using k means algorithm

The project's goal is to show a real world application of image segmentation using k means algorithm

null 2 Jan 22, 2022
An image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testingAn image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testing

SVM Données Une base d’images contient 490 images pour l’apprentissage (400 voitures et 90 bateaux), et encore 21 images pour fait des tests. Prétrait

Achraf Rahouti 3 Nov 30, 2021
Learning Generative Models of Textured 3D Meshes from Real-World Images, ICCV 2021

Learning Generative Models of Textured 3D Meshes from Real-World Images This is the reference implementation of "Learning Generative Models of Texture

Dario Pavllo 115 Jan 7, 2023
This project contains the ClonedPerson dataset and code described in our paper "Cloning Outfits from Real-World Images to 3D Characters for Generalizable Person Re-Identification".

ClonedPerson This is the official repository for the ClonedPerson project, which contains the ClonedPerson dataset and code described in our paper "Cl

Yanan Wang 55 Dec 27, 2022
Towards Open-World Feature Extrapolation: An Inductive Graph Learning Approach

This repository holds the implementation for paper Towards Open-World Feature Extrapolation: An Inductive Graph Learning Approach Download our preproc

Qitian Wu 42 Dec 27, 2022
A redesign of our previous Python World Cup, aiming to simulate the 2022 World Cup all the way from the qualifiers

A redesign of our previous Python World Cup, aiming to simulate the 2022 World Cup all the way from the qualifiers. This new version is designed to be more compact and more efficient and will reflect the improvements in our programming ability.

Sam Counsell 1 Jan 7, 2022
Face Library is an open source package for accurate and real-time face detection and recognition

Face Library Face Library is an open source package for accurate and real-time face detection and recognition. The package is built over OpenCV and us

null 52 Nov 9, 2022
Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels.

The Face Synthetics dataset Face Synthetics dataset is a collection of diverse synthetic face images with ground truth labels. It was introduced in ou

Microsoft 608 Jan 2, 2023
Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line

NAVER/LINE Vision 357 Jan 4, 2023