当前位置:网站首页>深度学习系列46:人脸图像超分GFP-GAN
深度学习系列46:人脸图像超分GFP-GAN
2022-06-23 06:18:00 【IE06】
1. 介绍
GFP-GAN由腾讯ARC实验室出品,测试下来效果很不错。
模型用于从低质量的人脸中恢复出高质量人脸。这些质量较低的肖像图可能由各种原因导致退化,如低分辨率,噪音,模糊或是被压缩。
主流的图像修复技术还是对抗生成网络GAN,但如何用好GAN是个学问。本模型使用了生成性面部先验模型(Generative Facial Prior, GFP),通过空间特征变换层被纳入到面部恢复过程中,这使得该方法能够实现真实性和保真度的良好平衡。
目前有3个pretrain模型,默认使用v1.3:
模型总图如下:
1.1 去退化模块

去退化模块为一个UNet,在UNet解码器的每个分辨率尺度输出图像,使用L1损失函数监督去退化模块。
1.2 Pretrained GAN as prior
将styleGAN的生成器拿过来直接用~
1.3 加入空间特征
用经过了重建损失函数的 F s p a t i a l F_{spatial} Fspatial可以更好的提高保真性,与前面的 F G A N F_{GAN} FGAN进行连接,连接方法为SFT。
1.4 增加面部成分损失、保真性损失

保真性损失使用ArcFace人脸识别模型。
2. 快速上手
2.1 测试地址
- https://huggingface.co/spaces/akhaliq/GFPGAN,仅返回人脸
- https://app.baseten.co/applications/Q04Lz0d/operator_views/8qZG6Bg,GPU backened,速度很快,而且可以返回全图
- https://replicate.com/xinntao/gfpgan,需要注册,返回全图
- colab demo地址:https://colab.research.google.com/drive/1sVsoBd9AjckIXThgtZhGrHRfFI6UUYOo
2.2 github地址
https://github.com/TencentARC/GFPGAN
git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN
pip install basicsr # 用于推理和训练,https://github.com/xinntao/BasicSR
pip install facexlib # 用于人脸检测,https://github.com/xinntao/facexlib
pip install -r requirements.txt
python setup.py develop
pip install realesrgan # 非人脸区域超分,使用Real-ESRGAN
然后下载模型,这里可以离线下载:
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models no-check-certificate
执行推理:
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
如果用cpu的话,有几个地方需要修改:
- inference_gfpgan.py中,允许cpu,并将half改为False:

此外,python3.7/site-packages/facexlib/utils中加上兼容cpu的代码:
边栏推荐
猜你喜欢

【STL】关联容器之unordered_map用法总结

ssm + ftp +ueditor
![[STL] summary of pair usage](/img/ba/72697f0f8bf018f1b5884e9cc2be4e.png)
[STL] summary of pair usage

WPF command directive and inotifypropertychanged

MySQL basic query

Open source oauth2 framework for SSO single sign on

Vs2013 ffmpeg environment configuration and common error handling

解决挖矿病毒 sshd2(redis未设密码、清除crontab定时任务)

English grammar_ Adjective comparative - Level 3 change

XXL-SSO 实现SSO单点登录
随机推荐
idea自动生成serialVersionUID
316. 去除重复字母
宝塔忘记密码
Solve the mining virus sshd2 (redis does not set a password and clear the crontab scheduled task)
WPF command directive and inotifypropertychanged
901. 股票价格跨度
【STL】关联容器之unordered_map用法总结
Add IPAD control function into shairplay
Linux安装mysql8.0.25
[STL] summary of deque usage of sequential containers
[project training] details of linear components
2022年养老理财产品有哪些?风险小的
Common setup modes (Abstract Factory & responsibility chain mode & observer mode)
[daily training] 513 Find the value in the lower left corner of the tree
Badly placed()'s problem
【STL】容器适配器之stack、queue用法总结
cmder
TP6 安装拓展
406-双指针(27. 移除元素、977.有序数组的平方、15. 三数之和、18. 四数之和)
解决挖矿病毒 sshd2(redis未设密码、清除crontab定时任务)