更多详细信息见Github仓库
GFP-GAN并未自带web交互页面,因此,克隆项目后,安装项目所需环境后,在运行前后需要自行在文件夹中放入和获取相关图片。
#克隆仓库
git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN
#安装依赖
apt-get update
apt-get install -y libgl1 git libglib2.0-0 pyyaml -i https://pypi.tuna.tsinghua.edu.cn/simple
依次安装以下包
pip install basicsr
pip install facexlib
pip install -r requirements.txt
运行代码:
python setup.py develop
下载模型v1.3版本:
wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models
模型v1.2版本为(可自行选择下载,放置在experiments/pretrained_models中):
https://github.com/TencentARC/GFPGAN/releases/download/v0.2.0/GFPGANCleanv1-NoCE-C2.pth
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