一、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
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.”