VideoColorizer.ipynb
#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)
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()
Type in a url hosting a video from YouTube, Imgur, Twitter, Reddit, Vimeo, etc. Many sources work! GIFs also work. Full list here: https://ytdl-org.github.io/youtube-dl/supportedsites.html NOTE: If you want to use your own video, you can set source_url to None and just upload the file to video/source/ in Jupyter. Just make sure that the file_name parameter matches the file you uploaded.
Name this whatever sensible file name you want (minus extension)! It should actually exist in video/source if source_url=None
The default value of 21 has been carefully chosen and should work -ok- for most scenarios (but probably won't be the -best-). This determines resolution at which the color portion of the video is rendered. Lower resolution will render faster, and colors also tend to look more vibrant. Older and lower quality film in particular will generally benefit by lowering the render factor. Higher render factors are often better for higher quality videos and inconsistencies (flashy render) will generally be reduced, but the colors may get slightly washed out.
There's no reason to changes this.
Ditto- don't change.
Simply shift+right click on the displayed video and click "Save video as..."!
The video player may wind up not showing up, in which case- make sure to wait for the Jupyter cell to complete processing first (the play button will stop spinning). Then follow these alternative download instructions
If a video you downloaded doesn't play, it's probably because the cell didn't complete processing and the video is in a half-finished state. If you get a 'CUDA out of memory' error, you probably have the render_factor too high. The max is 44 on 11GB video cards.
#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, render_factor=render_factor)
show_video_in_notebook(result_path)
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))