mirror of
https://github.com/jantic/DeOldify.git
synced 2026-09-21 12:43:13 +08:00
Add the watermark png back into the repo and remove the wget step from the Colab notebooks.
7.7 KiB
7.7 KiB
In [ ]:
!git clone https://github.com/jantic/DeOldify.git DeOldify In [ ]:
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.')In [ ]:
!pip install -r requirements-colab.txtIn [ ]:
import fastai
from deoldify.visualize import *
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")In [ ]:
!mkdir 'models'
!wget https://data.deepai.org/deoldify/ColorizeArtistic_gen.pth -O ./models/ColorizeArtistic_gen.pthIn [ ]:
colorizer = get_image_colorizer(artistic=True)In [ ]:
source_url = '' #@param {type:"string"}
render_factor = 35 #@param {type: "slider", min: 7, max: 40}
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,40,2):
colorizer.plot_transformed_image('test_images/image.png', render_factor=i, display_render_factor=True, figsize=(8,8))