3.3 KiB
3.3 KiB
In [ ]:
import os
os.environ['CUDA_VISIBLE_DEVICES']='3' In [ ]:
from fasterai.visualize import *
plt.style.use('dark_background')
torch.backends.cudnn.benchmark=TrueIn [ ]:
#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=25
#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'
file_name = 'TheHighSign1921.mp4'In [ ]:
colorizer = get_video_colorizer(render_factor=render_factor)In [ ]:
if source_url is not None:
colorizer.colorize_from_url(source_url, file_name)
else:
colorizer.colorize_from_file_name(file_name)In [ ]: