7.6 KiB
7.6 KiB
In [ ]:
import torch
if not torch.cuda.is_available():
print('GPU not available.')In [ ]:
!git clone https://github.com/jantic/DeOldify.git DeOldify In [ ]:
cd DeOldifyIn [ ]:
!pip install -r colab_requirements.txtIn [ ]:
import fastai
from deoldify.visualize import *
torch.backends.cudnn.benchmark = TrueIn [ ]:
!mkdir 'models'
!wget https://www.dropbox.com/s/zkehq1uwahhbc2o/ColorizeArtistic_gen.pth?dl=0 -O ./models/ColorizeArtistic_gen.pthIn [ ]:
!wget https://media.githubusercontent.com/media/jantic/DeOldify/master/resource_images/watermark.png -O ./resource_images/watermark.pngIn [ ]:
colorizer = get_image_colorizer(artistic=True)In [ ]:
source_url = '' #@param {type:"string"}
render_factor = 35 #@param {type: "slider", min: 7, max: 45}
watermarked = True #@param {type:"boolean"}
if source_url is not None and source_url !='':
image_path = colorizer.plot_transformed_image_from_url(url=source_url, render_factor=render_factor, compare=True. watermarked=watermarked)
show_image_in_notebook(image_path)
else:
print('Provide an image url and try again.')In [ ]:
for i in range(10,46,2):
colorizer.plot_transformed_image('test_images/image.png', render_factor=i, display_render_factor=True, figsize=(8,8))