再见旧照片,Python一键美颜!
数据管道
共 3537字,需浏览 8分钟
·
2020-10-02 02:06
点击上方“数据管道”,选择“置顶星标”公众号
干货福利,第一时间送达
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
评论