开源AI项目-老照片修复之 Bringing Old Photos Back to Life

方案 Bringing Old Photos Back to Life

https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life

快速开始

  1. 下载源码
git clone [email protected]:microsoft/Bringing-Old-Photos-Back-to-Life.git
  1. 下载Net模型
git clone [email protected]:vacancy/Synchronized-BatchNorm-PyTorch.git
  1. 下载预训练模型
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip
wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/global_checkpoints.zip
  1. 解压拷贝Net模型和训练模型到对应源码目录
# 拷贝Net模型到源码目录
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm Bringing-Old-Photos-Back-to-Life/Face_Enhancement/models/networks
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm Bringing-Old-Photos-Back-to-Life/Global/detection_models
# 预测模型
cp shape_predictor_68_face_landmarks.dat.bz2 Bringing-Old-Photos-Back-to-Life/Face_Detection
# 解压训练模型到源码目录
cp face_checkpoints.zip Bringing-Old-Photos-Back-to-Life/Face_Enhancement
cp global_checkpoints.zip Bringing-Old-Photos-Back-to-Life/Global
unzip face_checkpoints.zip
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
  1. 依赖安装
pip install -r requirements.txt
  1. 执行修复
# GPU可设置为0、1、2或0、2; 若使用CPU设置为-1
# 若要修复破损可使用--with_scratch参数
python run.py --input_folder E:\oldphtoto2  --output_folder E:\newphoto2 --GPU -1  --with_scratch

python run.py --input_folder E:\oldphtoto  --output_folder E:\newphoto --GPU -1


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

修复效果图:

##原图:
原图
原图2

修复后的图

#修复后的图
修复后的图2

猜你喜欢

转载自blog.csdn.net/EBDSoftware/article/details/128477554
old