mirror of
https://github.com/jantic/DeOldify.git
synced 2026-11-03 14:34:49 +08:00
3.4 KiB
3.4 KiB
In [ ]:
import os
os.environ['CUDA_VISIBLE_DEVICES']='1' 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 64 on 11GB GPU). The default here works for most photos.
#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://vimeo.com/87890004'
#source_url = 'https://www.youtube.com/watch?v=gZShc8oshtU'
#source_url = 'https://www.youtube.com/watch?v=fk6qiJjEEBo'
#source_url = 'https://twitter.com/silentmoviegifs/status/1088830101863759872'
#source_url = 'https://i.imgur.com/Ob9pZad.gifv'
source_url = None
#file_name = 'BusterKeatonTrainHouse_Original.mp4'
#file_name = 'BicycleThief_Original.mp4'
#file_name = 'ChaplinParty_Original.mp4'
file_name = 'video14.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 [ ]: