It will be better to do:
from deoldify import visualize
Than:
from fasterai import visualize
The PyPI package will be called DeOldify, in this case
it makes more sense to have an import name that matches
the package name.
Also, fasterai resembles fastai library, and DeOldify
is not a library to use with fastai, it's built on
top of it.
5.9 KiB
5.9 KiB
In [ ]:
import os
os.environ['CUDA_VISIBLE_DEVICES']='0' In [ ]:
from deoldify.visualize import *
plt.style.use('dark_background')
torch.backends.cudnn.benchmark=TrueIn [ ]:
colorizer = get_video_colorizer()In [ ]:
#NOTE: Max is 44 with 11GB video cards. 21 is a good default
render_factor=21
#NOTE: Make source_url None to just read from file at ./video/source/[file_name] directly without modification
source_url='https://twitter.com/silentmoviegifs/status/1116751583386034176'
file_name = 'DogShy1926'
file_name_ext = file_name + '.mp4'
result_path = None
if source_url is not None:
result_path = colorizer.colorize_from_url(source_url, file_name_ext, render_factor=render_factor)
else:
result_path = colorizer.colorize_from_file_name(file_name_ext)
show_video_in_notebook(result_path)In [ ]:
for i in range(10,45,2):
colorizer.vis.plot_transformed_image('video/bwframes/' + file_name + '/00001.jpg', render_factor=i, display_render_factor=True, figsize=(8,8))In [ ]: