Skip to content

Latest commit



166 lines (133 loc) · 5.18 KB

File metadata and controls

166 lines (133 loc) · 5.18 KB

Simple Colorization

This MLHub package supports a pre-built model from Yang Liu providing an example of photo colorization using deep neural networks. For the demonstration a sample of provided black and white photos are colorized and displayed. You can add colour to your own local photos, a folder of photos, a photo on the Internet using the color command line tool.

Visit the github repository for more details:


  • To install mlhub (Ubuntu)

    $ pip3 install mlhub
  • To install and configure the package:

    $ ml install   colorize
    $ ml configure colorize

Command Line Tools

A demonstration of the package is presented below using the demo command. The package also provides a number of useful command line tools which we introduce here.

Colorize Photos

The color command will colorize a photo and optionally (--interactive) display the original and the colorized versions.

The command is useful in the context of colourising multiple photos, perhaps thousands of them by invoking the command with a single file argument on the command line, multiple files listed on the command line, a path to a folder containing photos, or the URL of an online photo.

To colorize a photo from a local file and to display the result interactively:

$ ml color colorize --interactive image_07_bw.png

The colorized photo will be saved into the file image_07_bw_color.png, within the local folder, noting the addition of the _color suffix.

The text output from the command is the name ofthe original photo file and the generated photo file. This can be piped into other commands for further processing. Thus, you can use your own tool to view the photo's if you wish:

$ ml color colorize image_07_bw.png |
  cut -d, -f2 |
  xarg display

To colorize images in a folder:

$ ml color colorize ~/.mlhub/colorize/images

This will save the colorized photos into the local folder from where the command is run.

To colorize an image from the web:

$ ml color colorize,black-and-white-flowers-wallpaper2_color.jpg
$ ml color colorize,black-and-white-flower-wallpaper1-310x165_color.jpg

To interatively colorize without repeatedly reloading the model:

$ ml color colorize --interactive
Path or URL of images to colorize (Quit by Ctrl-d):
(You could try images in '~/.mlhub/colorize/images/')

Path or URL of images to colorize (Quit by Ctrl-d):

Path or URL of images to colorize (Quit by Ctrl-d):


$ ml demo colorize
Loading the required Python modules ...

Loading the model ...
Demonstrate colorization using images found in

Please close each image (Ctrl-w) to proceed through the demonstration.

Colorize image_01_bw.png

Colorize image_02_bw.png

Colorize image_03_bw.png

Colorize image_04_bw.png

Colorize image_05_bw.png

Colorize image_06_bw.png

Colorize image_07_bw.png

Colorize image_09_bw.png

Colorize image_10_bw.png

To colorize images given by a path or URL:

  $ ml color colorize <path>