As mentioned, pix2pix has two networks: a generator and a discriminator. The generator is inspired by the architecture of U-Net. Similarly, the discriminator network is inspired by the architecture of PatchGAN. We will implement both networks in the following sections.
Before starting to write the implementations, create a Python file main.py and import the essential modules as follows:
import os
import time
import h5py
import keras.backend as K
import matplotlib.pyplot as plt
import numpy as np
from cv2 import imwrite
from keras import Input, Model
from keras.layers import Convolution2D, LeakyReLU, BatchNormalization, UpSampling2D, Dropout, Activation, Flatten, Dense, Lambda, Reshape, concatenate
from keras.optimizers import Adam