image_output_1.png
from keras.layers import Input, Dense, Dropout, Flatten, Conv2D, MaxPool2D, BatchNormalization, MaxPooling2D, BatchNormalization, UpSampling2D

from keras.models import Sequential, Model

INPUT_DIM = (144, 144, 1)
BATCH_SIZE = 128
EPOCHS = 100
LOSS = 'mse'
METRICS = ['accuracy']
OPTIMIZER = 'adam'

def Colorize():
    encoder_input = Input(shape=INPUT_DIM)
    encoder_output = Conv2D(64, (3, 3), activation='relu', padding='same', strides=2)(encoder_input)
    encoder_output = Conv2D(128, (3, 3), activation='relu', padding='same')(encoder_output)
    encoder_output = Conv2D(128, (3, 3), activation='relu', padding='same', strides=2)(encoder_output)
    encoder_output = Conv2D(256, (3, 3), activation='relu', padding='same')(encoder_output)
    encoder_output = Conv2D(256, (3, 3), activation='relu', padding='valid', strides=3)(encoder_output)
    encoder_output = Conv2D(512, (3, 3), activation='relu', padding='same')(encoder_output)
    encoder_output = Conv2D(512, (3, 3), activation='relu', padding='same')(encoder_output)
    encoder_output = Conv2D(256, (3, 3), activation='relu', padding='same')(encoder_output)
    decoder_output = Conv2D(128, (3, 3), activation='relu', padding='same')(encoder_output)
    decoder_output = UpSampling2D((3, 3))(decoder_output)
    decoder_output = Conv2D(64, (3, 3), activation='relu', padding='same')(decoder_output)
    decoder_output = UpSampling2D((2, 2))(decoder_output)
    decoder_output = Conv2D(32, (3, 3), activation='relu', padding='same')(decoder_output)
    decoder_output = Conv2D(16, (3, 3), activation='relu', padding='same')(decoder_output)
    decoder_output = Conv2D(3, (3, 3), activation='tanh', padding='same')(decoder_output)
    decoder_output = UpSampling2D((2, 2))(decoder_output)
    model = Model(inputs=encoder_input, outputs=decoder_output)
    return model
model = Colorize()
model.compile(optimizer=OPTIMIZER, loss=LOSS, metrics=METRICS)
model.summary()