mirror of
https://github.com/jantic/DeOldify.git
synced 2026-10-31 03:14:33 +08:00
Add the watermark png back into the repo and remove the wget step from the Colab notebooks.
9.7 KiB
9.7 KiB
In [ ]:
!git clone https://github.com/jantic/DeOldify.git DeOldifyIn [ ]:
cd DeOldifyIn [ ]:
#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)
import torch
if not torch.cuda.is_available():
print('GPU not available.')
from os import pathIn [ ]:
!pip install -r requirements-colab.txtIn [ ]:
import fastai
from deoldify.visualize import *
from pathlib import Path
torch.backends.cudnn.benchmark=True
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")In [ ]:
!mkdir 'models'
!wget https://data.deepai.org/deoldify/ColorizeVideo_gen.pth -O ./models/ColorizeVideo_gen.pthIn [ ]:
colorizer = get_video_colorizer()In [ ]:
source_url = '' #@param {type:"string"}
render_factor = 21 #@param {type: "slider", min: 5, max: 40}
watermarked = True #@param {type:"boolean"}
if source_url is not None and source_url !='':
video_path = colorizer.colorize_from_url(source_url, 'video.mp4', render_factor, watermarked=watermarked)
show_video_in_notebook(video_path)
else:
print('Provide a video url and try again.')In [ ]:
for i in range(10,40,2):
colorizer.vis.plot_transformed_image('video/bwframes/video/00001.jpg', render_factor=i, display_render_factor=True, figsize=(8,8))