As discussed earlier in this chapter in the An Introduction to CycleGANs section, CycleGANs have two network architectures, a generator and a discriminator network. In this section, we will write the implementation for all the networks.
Before starting to write the implementations, however, create a Python file, main.py, and import the essential modules, as follows:
from glob import glob
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from keras import Input, Model
from keras.layers import Conv2D, BatchNormalization, Activation, Add, Conv2DTranspose,
ZeroPadding2D, LeakyReLU
from keras.optimizers import Adam
from keras_contrib.layers import InstanceNormalization
from scipy.misc import imread, imresize