老照片修复

一、Bringing-Old-Photos-Back-to-Life

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

1.新建环境 配置python、torch

conda create -n old_photos python=3.8
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

2.下载安装Bringing-Old-Photos-Back-to-Life:

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

先cd到Bringing-Old-Photos-Back-to-Life目录:

# 克隆 Synchronized-BatchNorm-PyTorch 存储库
cd Face_Enhancement/models/networks/
git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
cd ../../../

cd Global/detection_models
git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
cd ../../

# 下载地标检测(landmark detection)预训练模型
cd Face_Detection/
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
cd ../

# 下载预训练模型,将文件放在Face_Enhancement/checkpoints.zip下./Face_Enhancement,将文件放在Global/checkpoints.zip下./Global。然后分别解压它们。
cd Face_Enhancement/
wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip
unzip face_checkpoints.zip
cd ../
cd Global/
wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/global_checkpoints.zip
unzip global_checkpoints.zip
cd ../
# 安装依赖项:
pip install -r requirements.txt

3、运行

python run.py --input_folder 00input --output_folder 00output --GPU 0

dhy:
python run.py --input_folder 00shanding/input --output_folder 00shanding/output --GPU 0 --with_scratch --HR

报错!

1、安装dilb报错:

pip install cmake
pip install boost

git clone https://github.com/davisking/dlib.git

# 查看gcc版本
gcc -v

# if gcc 5.4
cd dlib
python setup.py install

# if gcc 4.8 
git checkout v19.21  # 切换到v19.21版本
python setup.py install

参考 (linux下) 无痛安装dlib

2、INTEL MKL ERROR: */anaconda3/lib/libmkl_avx512.so: undefined symbol: mkl_sparse_op

conda install -f numpy

参考 https://www.cnblogs.com/myblog1993/p/9317944.html

3、Cannot cast ufunc ‘multiply’ output from dtype(‘float64’) to dtype(‘uint8’) with casting rule ‘same_kind’

在这里插入图片描述
改为 mask = (mask * 255.0)
参考 Numpy Cannot cast ufunc multiply output from dtype

二、GFPGAN

https://github.com/TencentARC/GFPGAN

0、新建环境 配置python、torch

conda create -n gfpgan python=3.8
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

先cd 到文件夹目录

1、克隆仓库

git clone https://github.com/TencentARC/GFPGAN.git
cd GFPGAN

2、安装依赖包

# Install basicsr - https://github.com/xinntao/BasicSR
# We use BasicSR for both training and inference
pip install basicsr

# Install facexlib - https://github.com/xinntao/facexlib
# We use face detection and face restoration helper in the facexlib package
pip install facexlib

pip install -r requirements.txt
python setup.py develop

# If you want to enhance the background (non-face) regions with Real-ESRGAN,
# you also need to install the realesrgan package
pip install realesrgan

3、下载预训练模型

GFPGANv1.3.pth:

wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models

4、推理!

python inference_gfpgan.py -i inputs/whole_imgs -o output -v 1.3 -s 2

报错!

1、‘GET was unable to find an engine to execute this computation’

在这里插入图片描述
torch的版本问题。 预先装好torch就行了。

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

2、v1版本报错:name ‘fused_act_ext’ is not defined

# 可能需要安装
pip install ninja

运行前加上export BASICSR_JIT='True'
还是有问题:“You’re running a too old version of GCC. We need GCC 5 or later.”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值