Build a Pix2Pix GAN With Python

Wendee ๐Ÿ’œ๐Ÿ•
The Startup
Published in
6 min readSep 12, 2020

--

There are times that we want to transform an image into another style. Letโ€™s say we have a fine collection of sketches. Our daily work is to colour these black and white images.

image from this kaggle dataset

It might be interesting if the number of tasks is small, but when it comes to hundreds of sketches a day, hmmmโ€ฆ maybe we need some help. This is where GAN comes to rescue. Generative Adversarial Network, or GAN, is a machine learning framework that aims to generate new data with the same distribution as the one in the training dataset. In this article, we will build a pix2pix GAN that takes an image as input, and later outputs another image.

This is the amazing work demonstrated in this paper

To break things down, we will go through these steps:

  1. Prepare our data
  2. Build the network
  3. Train the network
  4. Test and see the results

Prepare our data

In image transformation, we need to have an original image and its expected transformed result. It is recommended to have more than thousands of this kind of before-after-pairs. (Yes, GAN needs a lot of image ๐Ÿ˜…) In this post, we will use data from this kaggle dataset.

--

--