其他
百年老照片修复算法,那些高颜值的父母!
点击上方“Jack Cui”,选择“加为星标”
第一时间关注技术干货!
1
2
黑白照片上色,是一个经典上色老算法(2018年):
「DeOldify」
git clone https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life
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 ../../
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 ../
python run.py --input_folder [test_image_folder_path] \
--output_folder [output_path] \
--GPU 0
将你想修复的图片放到 [test_image_folder_path] 目录下(自己指定),生成的图片会放到 [output_path] 目录中。
python run.py --input_folder [test_image_folder_path] \
--output_folder [output_path] \
--GPU 0 \
--with_scratch
2、DeOldify
#NOTE: This must be the first call in order to work properly!
from deoldify import device
from deoldify.device_id import DeviceId
#choices: CPU, GPU0...GPU7
device.set(device=DeviceId.GPU0)
import torch
if not torch.cuda.is_available():
print('GPU not available.')
import fastai
from deoldify.visualize import *
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
colorizer = get_image_colorizer(artistic=True)
colorizer.plot_transformed_image("test_images/1.png", render_factor=10, compare=True)
3