Files
Praveenhalder-ComfyUI-DeOldify/ImageColorizerColab.ipynb
T

5.8 KiB

Open In Colab

#◢ DeOldify - Colorize your own photos!

####Credits:

Special thanks to:

Matt Robinson and María Benavente for pioneering the DeOldify image colab notebook.

Dana Kelley for doing things, breaking stuff & having an opinion on everything.


#◢ Verify Correct Runtime Settings

IMPORTANT

In the "Runtime" menu for the notebook window, select "Change runtime type." Ensure that the following are selected:

  • Runtime Type = Python 3
  • Hardware Accelerator = GPU
In [ ]:
from os import path
import torch

#◢ Git clone and install DeOldify

In [ ]:
!git clone -b FastAIv1 --single-branch https://github.com/jantic/DeOldify.git DeOldify
#!git clone https://github.com/jantic/DeOldify.git DeOldify 
In [ ]:
cd DeOldify

#◢ Setup

In [ ]:
!pip install -e .
In [ ]:
import fastai
from fasterai.visualize import *
from pathlib import Path
torch.backends.cudnn.benchmark=True
In [ ]:
!mkdir 'models'
!wget wget https://www.dropbox.com/s/zkehq1uwahhbc2o/ColorizeArtistic_gen.pth?dl=0 -O ./models/ColorizeArtistic_gen.pth
In [ ]:
colorizer = get_image_colorizer(artistic=True)

#◢ Colorize!!

Instructions

source_url

Any direct link to an image should do (will end with extension .jpg, .png, etc). NOTE: If you want to use your own image, upload it first to a site like Imgur.

render_factor

The default value of 35 has been carefully chosen and should work -ok- for most scenarios (but probably won't be the -best-). This determines resolution at which the photo is rendered. Lower resolution will render faster, and colors also tend to look more vibrant. Older and lower quality photos in particular will generally benefit by lowering the render factor. Higher render factors are often better for higher quality photos.

How to Download a Copy

Simply right click on the displayed image and click "Save image as..."!

In [ ]:
source_url = '' #@param {type:"string"}
render_factor = 35  #@param {type: "slider", min: 7, max: 46}

if source_url is not None and source_url !='':
    image_path = colorizer.plot_transformed_image_from_url(url=source_url, render_factor=render_factor)
    show_image_in_notebook(image_path)
else:
    print('Provide an image url and try again.')

#⚙ Recommended image sources