Translating unpaired images with CycleGAN
In the Translating images with Pix2Pix recipe, we discovered how to transfer images from one domain to another. However, in the end, it's supervised learning that requires a pairing of input and target images in order for Pix2Pix to learn the correct mapping. Wouldn't it be great if we could bypass this pairing condition, and let the network figure out on its own how to translate the characteristics from one domain to another, while preserving image consistency?
Well, that's what CycleGAN does, and in this recipe, we'll implement one from scratch to convert pictures of Yosemite National Park taken during the summer into their winter counterparts!
Let's get started.
Getting ready
We'll use OpenCV
, tqdm
, and tensorflow-datasets
in this recipe.
Install these simultaneously with pip
:
$> pip install opencv-contrib-python tqdm tensorflow-datasets
Through the TensorFlow datasets, we'll...