1.github官网下载源码
2.配置深度学习环境
3.下载模型
4.照片上色代码

from deoldify import device
from deoldify.device_id import DeviceId
#choices:  CPU, GPU0...GPU7
device.set(device=DeviceId.GPU1)
from deoldify.visualize import *

plt.style.use('dark_background')
torch.backends.cudnn.benchmark=True

import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")

colorizer = get_image_colorizer(artistic=True)

render_factor=35

source_path = 'test_images/th.jpg'

result_path = None

colorizer.plot_transformed_image(path=source_path, render_factor=render_factor, compare=True)

5.视频上色代码(推荐使用GPU训练)

from deoldify import device
from deoldify.device_id import DeviceId
#choices:  CPU, GPU0...GPU7
from jedi.api import file_name

device.set(device=DeviceId.GPU1)

from deoldify.visualize import *
plt.style.use('dark_background')
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")

colorizer = get_video_colorizer()

#NOTE:  Max is 44 with 11GB video cards.  21 is a good default
render_factor=2

file_name='qwe'
file_name_ext = file_name + '.mp4'
result_path = None

colorizer.colorize_from_file_name(file_name_ext, render_factor=render_factor)

6.对该项目感兴趣或者照片,视频上色的可以联系博主