🚀 感谢你对我们工作的关注。你可能还想查看我们关于Real-ESRGAN中动漫图像和视频的微型模型的新更新 😊
GFPGAN旨在开发一种用于真实世界面部修复的实用算法。
它利用封装在预训练面部 GAN(例如 StyleGAN2)中的丰富多样的先验进行盲脸恢复。
❓ 常见问题可以在 FAQ.md 中找到。
🚩 更新
如果GFPGAN对你的照片/项目有帮助,请帮助⭐这个回购或推荐给你的朋友。谢谢😊
其他推荐项目: Real-ESRGAN:一种实用的通用图像恢复算法 BasicSR:一个开源的图像和视频恢复
我们现在提供 GFPGAN 的干净版本,它不需要自定义的 CUDA 扩展。
如果你想使用我们论文中的原始模型,请参阅 PaperModel.md 进行安装。
克隆存储库
git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN
安装依赖包
# 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 进行安装和推理。
版本 | 型号名称 | 描述 |
---|---|---|
1.3版 | GFPGANv1.3.pth | 基于 V1.2;更自然的恢复效果;在非常低质量/高质量的输入上获得更好的结果。 |
V1.2版本 | GFPGANCleanv1-NoCE-C2.pth | 无着色;不需要 CUDA 扩展。通过预处理使用更多数据进行训练。 |
V1 | GFPGANv1.pth | 纸张模型,带着色。 |
比较是 Comparisons.md。
请注意,V1.3 并不总是比 V1.2 好。你可能需要根据你的目的和输入选择不同的模型。
版本 | 优势 | 弱点 |
---|---|---|
1.3版 | ✓ 自然输出 ✓在非常低质量的输入上获得更好的结果 ✓ 在相对高质量的输入上工作 ✓ 可以重复(两次)修复 |
✗ 不是很犀利 ✗ 身份略有变化 |
V1.2版本 | ✓ 更清晰的输出 ✓ 与美容妆容 |
✗ 有些输出不自然 |
你可以在此处找到更多模型(例如鉴别器):[Google Drive]或 [Tencent Cloud 腾讯微云]
我们提供了GFPGAN的训练代码(在我们的论文中使用)。
你可以根据自己的需要对其进行改进。
技巧
程序
(你可以尝试不需要人脸组件地标的简单版本 ( )。
options/train_gfpgan_v1_simple.yml
数据集准备:FFHQ
下载预训练模型和其他数据。将它们放在文件夹中。
experiments/pretrained_models
相应地修改配置文件。
options/train_gfpgan_v1.yml
训练
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 下发布。
@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} }
如果你有任何问题,请发送电子邮件或。
xintao.wang@outlook.com
xintaowang@tencent.com