首頁>編程相關>Python
  1. 更新在線演示:。這是備份。
  2. 更新在線演示:
  3. GFPGAN的COLAB演示; (原始紙模型的另一個COLAB演示)

感謝您對我們的工作的興趣。您可能還想檢查我們在Real-Esrgan中有關動漫圖像和視頻小型模型的新更新嗎?

GFPGAN旨在開發一種實用算法,用於現實世界的面部修復
它利用封裝在經過驗證的面孔(例如stylegan2)中的豐富而多樣的先驗來進行盲人臉部修復。

❓常見問題可以在常見問題中找到。

更新


如果GFPGAN在您的照片/項目中有所幫助,請幫助此存儲庫或向您的朋友推薦。謝謝?其他推薦項目:
▶q Real-esrgan:用於一般圖像修復的實用算法
▶q基礎知識:開源圖像和視頻修復工具箱
▶q facexlib:提供有用的面部關係功能的集合
▶q Handyview:基於PYQT5的圖像查看器,可用於查看和比較


GFP-GAN:朝著現實世界的盲人面部恢復,具有生成性面部先驗

[紙] [項目頁] [演示]
Xintao Wang,Yu Li,Honglun Zhang,Ying Shan
應用研究中心(ARC),騰訊PCG


?依賴項和安裝

安裝

現在,我們提供了GFPGAN的乾淨版本,該版本不需要定制的CUDA擴展。
如果您想在我們的論文中使用原始型號,請參閱papermodel.md進行安裝。

  1. 克隆回購

    git clone https://github.com/TencentARC/GFPGAN.git
    cd GFPGAN
  2. 安裝因軟件包

     # 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

⚡快速推斷

我們以v1.3版本為例。可以在這裡找到更多型號。

下載預訓練的模型:gfpganv1.3.pth

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

推理!

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

如果您想在我們的論文中使用原始型號,請參閱papermodel.md進行安裝和推理。

?模型動物園

版本模型名稱描述
v1.3 gfpganv1.3.pth基於v1.2;更自然的恢復結果;在非常低質量 /高質量的輸入方面更好的結果。
v1.2 gfpgancleanv1-noce-c2.pth沒有著色;不需要CUDA擴展。接受了更多數據進行預處理培訓。
V1 gfpganv1.pth紙質模型,帶有著色。

比較是比較。

請注意,v1.3並不總是比v1.2好。您可能需要根據您的目的和輸入選擇不同的模型。

版本優勢弱點
v1.3 ✓自然產出
✓非常低質量的輸入結果
✓處理相對較高的輸入
✓可以重複(兩次)修復
✗不是很清晰
✗身份有輕微的改變
v1.2 ✓銳利的輸出
✓帶有美容妝
✗有些輸出不自然

您可以在此處找到更多模型(例如歧視器) :[Google Drive]或[Tencent Cloud騰訊微雲]

訓練

我們提供GFPGAN的培訓代碼(在我們的論文中使用)。
您可以根據自己的需求改進它。

尖端

  1. 高質量的面孔可以提高恢復質量。
  2. 您可能需要執行一些預處理,例如美容妝。

程式

(您可以嘗試一個簡單的版本( options/train_gfpgan_v1_simple.yml ),不需要面部分量地標。)

  1. 數據集準備:FFHQ

  2. 下載預訓練的模型和其他數據。將它們放入experiments/pretrained_models文件夾中。

    1. 預訓練stylegan2型號:stylegan2_512_cmul1_ffhq_b12g4_scratch_800k.pth
    2. FFHQ的組件位置:ffhq_eye_mouth_landmarks_512.pth
    3. 一個簡單的弧形型號:arcface_resnet18.pth
  3. 相應地修改配置文件options/train_gfpgan_v1.yml

  4. 訓練

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

許可和確認

GFPGAN由Apache許可證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}
}

?接觸

如果您有任何疑問,請發送電子郵件[email protected][email protected]

展開
附加信息