照片修复-GPEN框架

发布时间:2024年01月22日

一 照片修复-GPEN介绍:

? ? ? ? ? gpen是一个优秀的照片修复框架,关键是开源的,它是基于GAN先验嵌入网络的野外盲脸复原,特别是针对人脸修复效果特别好,先看一下官方的效果图:

修复效果图前后对比:

二? 安装GPEN

?1 下载GPEN

? ?从github下载GPEN源码

git clone https://github.com/yangxy/GPEN.git
cd GPEN

?2 安装GPEN环境

? 安装搭建环境与依赖

pip install "modelscope[cv]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

?安装项目依赖包:?

pip install -r requirements.txt 

安装?torch

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

环境安装完后占用大概大小(不同的版本,大小也不同)

?3 下载项目数据模型:

[RetinaFace-R50](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/RetinaFace-R50.pth) 
 [ParseNet-latest](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/ParseNet-latest.pth) | [model_ir_se50](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/model_ir_se50.pth) | [GPEN-BFR-512](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-512.pth) | [GPEN-BFR-512-D](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-512-D.pth) | [GPEN-BFR-256](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-256.pth) | [GPEN-BFR-256-D](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-BFR-256-D.pth) | [GPEN-Colorization-1024](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-Colorization-1024.pth) | [GPEN-Inpainting-1024](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-Inpainting-1024.pth) | [GPEN-Seg2face-512](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/GPEN-Seg2face-512.pth) | [realesrnet_x1](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/realesrnet_x1.pth) | [realesrnet_x2](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/realesrnet_x2.pth) | [realesrnet_x4](https://public-vigen-video.oss-cn-shanghai.aliyuncs.com/robin/models/realesrnet_x4.pth)

如下图,已下载好放在weights目录下:

? 三 运行GPEN修复照片

python demo.py --task FaceEnhancement --model GPEN-BFR-512 --in_size 512 --channel_multiplier 2 --narrow 1 --use_sr --sr_scale 4 --use_cuda --save_face --indir examples/imgs --outdir examples/outs-bfr

修复生成图片文件

修复前后对比图 1

?修复前后对比图 2

Solvay_conference_1927_face00.jpg

?看上去非常清晰,这里只选了?GPEN-BFR-512就有如此效果,很完美。还有其它数据模型,待测试中。

文章来源:https://blog.csdn.net/qyhua/article/details/135717521
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。