Creating Galaxy Images with GANs

Pix2Pix GANs are used for image-to-image translation. Image-to-image translation changes the style of an input image to a target style: it tries to map input image → output image.

Image-to-image translation(Source: https://towardsdatascience.com/image-to-image-translation-69c10c18f6ff)

In this article, we will see how to build a model to create galaxy images from noisy pictures. An example is below:

Left: Noisy image, Right: Generated Galaxy Image

Dataset Generation

I had to create a dataset from scratch as there are lots of galaxy image datasets but none of them really fit this purpose. After some thinking, I came up with an idea. First of all, lots of galaxy images were downloaded from google images. For each image, I had created an edge map using Canny edge detection. Based on the strength of the threshold, we get different quality edge maps. With a weaker threshold, we get a noisy image that roughly sketches the outline of the galaxy.

Input: Canny edge image of Galaxy on the right, Target: Galaxy on the right

The Canny edge image looks noisy and we will create a training pair like this: (Canny edge image of Galaxy, Original Galaxy Image)

The Image-to-image translation task is to translate a noisy image into a galaxy style image.

Training

To train my GAN, I followed the classic Tensorflow tutorial: pix2pix: Image-to-image translation with a conditional GAN*

The code is embedded below but you can also find it here.

Results

After training, the h5 model was saved and used for predictions as shown below.

The code can be found here.

Gallery

Live prediction

MSc Computer Vision, Graphics and Imaging, University College London