DeOldify黑白旧照片着色神器:基于NoGAN的深度学习来实现旧照着色还原。以及旧视频修复着色、插画着色、素描着色等。
参考:https://baiyue.one/archives/1692.html
源码: https://github.com/jantic/DeOldify
【安装】
获取源码:
git clone https://github.com/jantic/DeOldify.git DeOldify && cd DeOldify
下载模型:
mkdir 'models' && wget https://www.dropbox.com/s/zkehq1uwahhbc2o/ColorizeArtistic_gen.pth?dl=0 -O ./models/ColorizeArtistic_gen.pth
安装项目需要用到到Pytorch等python的库:
pip install -r requirements.txt
【使用】
运行代码:
import torch if not torch.cuda.is_available(): print('GPU not available.') import fastai from deoldify.visualize import * torch.backends.cudnn.benchmark = True colorizer = get_image_colorizer(artistic=True) source_url = 'https://i.redd.it/x8vuzbvl84n51.jpg' #@param {type:"string"} render_factor = 25 #@param {type: "slider", min: 7, max: 45} if source_url is not None and source_url !='': image_path = colorizer.plot_transformed_image_from_url(url=source_url, render_factor=render_factor, compare=True) show_image_in_notebook(image_path) else: print('Provide an image url and try again.')