16.03.2021 Views

Advanced Deep Learning with Keras

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7

return

dirs=dirs,

show=True)

# build the cyclegan for cifar10 colorization

models = build_cyclegan(shapes,

"gray-%s" % postfix,

"color-%s" % postfix,

kernel_size=kernel_size,

patchgan=patchgan)

# patch size is divided by 2^n since we downscaled the input

# in the discriminator by 2^n (ie. we use strides=2 n times)

patch = int(source_data.shape[1] / 2**4) if patchgan else 1

params = (batch_size, train_steps, patch, model_name)

test_params = (titles, dirs)

# train the cyclegan

train_cyclegan(models,

data,

params,

test_params,

other_utils.test_generator)

Generator outputs of CycleGAN

Figure 7.1.9 shows the colorization results of CycleGAN. The source images are

from the test dataset. For comparison, we show the ground truth and the colorization

results using a plain autoencoder described in Chapter 3, Autoencoders. Generally, all

colorized images are perceptually acceptable. Overall, it seems that each colorization

technique has both its own pros and cons. All colorization methods are not consistent

with the right color of the sky and vehicle.

For example, the sky in the background of the plane (3 rd row, 2 nd column) is white.

The autoencoder got it right, but the CycleGAN thinks it is light brown or blue.

For the 6 th row, 6 th column, the boat on the dark sea had an overcast sky but was

colorized with blue sky and blue sea by autoencoder and blue sea and white sky

by CycleGAN without PatchGAN. Both predictions make sense in the real world.

Meanwhile, the prediction of CycleGAN with PatchGAN is similar to the ground

truth. On 2 nd to the last row and 2 nd column, no method was able to predict the

red color of the car. On animals, both flavors of CycleGAN have closer colors to

the ground truth.

[ 225 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!