当前位置:网站首页>深度学习系列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的代码:
边栏推荐
- 【项目实训】线形箭头的变化
- 解决挖矿病毒 sshd2(redis未设密码、清除crontab定时任务)
- 回调函数详解
- English grammar_ Adverb - ever / once
- QT designer cannot modify the window size, and cannot change the size by dragging the window with the mouse
- xml schem 记录
- Anti chicken soup speech
- QT method of compiling projects using multithreading
- mysql 基础查询
- [project training] multi segment line expanded to parallel line
猜你喜欢

MySQL Redo log Redo log

Idea installing the cloudtoolkit plug-in

云原生落地进入深水区,博云容器云产品族释放四大价值

MySQL重做日志 redo log

Run typescript code directly using TS node

Eureka

Children's programming for comprehensively cultivating students' mental thinking

English grammar_ Adjective comparative - Level 3 change
![[STL] summary of deque usage of sequential containers](/img/33/65c54d14697ee43b2655ea1255d67d.png)
[STL] summary of deque usage of sequential containers

Xiaobai must see in investment and wealth management: illustrated fund buying and selling rules
随机推荐
Summarized benefits
994. rotten oranges - non recursive method
excel高级绘图技巧100讲(八)-Excel绘制WIFI图
Badly placed()'s problem
core. What is JS ---kalrry
[saison de remise des diplômes · technologie agressive er] votre choix, agenouillez - vous et partez
mysql 索引
Open source oauth2 framework for SSO single sign on
Problem: when the attribute in the data object (defined data) in the access component is also the attribute in the object object, an error is reported
306. 累加数
994. 腐烂的橘子-非递归法
Common setup modes (Abstract Factory & responsibility chain mode & observer mode)
JS dynamically creates a href circular download file. Only 10 or a fixed number of files can be downloaded
ssm + ftp +ueditor
Children's programming for comprehensively cultivating students' mental thinking
Add IPAD control function into shairplay
Concepts and differences of DQL, DML, DDL and DCL
[bull Chinese document] queue package used to process distributed jobs and messages in nodejs
301. 删除无效的括号
Anti chicken soup speech