Files
Praveenhalder-ComfyUI-DeOldify/VideoColorizer.ipynb
T

3.5 KiB

In [ ]:
import os
os.environ['CUDA_VISIBLE_DEVICES']='0' 
In [ ]:
from fasterai.visualize import *
plt.style.use('dark_background')
torch.backends.cudnn.benchmark=True
In [ ]:
#Adjust render_factor (int) if image doesn't look quite right (max 45 on 11GB GPU).  
#Lower render factors (as low as 12-15) tend to work well for old and low quality videos.
#High render factors (25-45) tend to work well for higher quality and more recent videos

#Not satisfied with color saturation?  Lower the render factor.  
#Unacceptable object flicker?  Increase the render factor.

#It literally just is a number multiplied by 16 to get the square render resolution.  
#Note that this doesn't affect the resolution of the final output- the output is the same resolution as the input.
#Example:  render_factor=21 => color is rendered at 16x21 = 336x336 px.  
render_factor=21
#Specify media_url. Many sources will work (YouTube, Imgur, Twitter, Reddit, etc). 
#Complete list here: https://rg3.github.io/youtube-dl/supportedsites.html. 
#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/1112256563182489600'
#source_url='https://archive.org/details/impact'
source_url='https://twitter.com/silentmoviegifs/status/1116751583386034176'
file_name = 'DogBath.mp4'
In [ ]:
colorizer = get_video_colorizer()
In [ ]:
if source_url is not None:
    video_path = colorizer.colorize_from_url(source_url, file_name, render_factor=render_factor)
    show_video_in_notebook(video_path)
else:
    video_path = colorizer.colorize_from_file_name(file_name)
    show_video_in_notebook(video_path)
In [ ]: