3. Semantic segmentation network in Keras
As shown in Figure 12.2.3, we already have some of the key building blocks of our semantic segmentation network. We can reuse the ResNet model presented in Chapter 2, Deep Neural Networks. We just need to build the features' pyramid and the upsampling and prediction layers.
Borrowing the ResNet model that we developed in Chapter 2, Deep Neural Networks, and which was reused in Chapter 11, Object Detection, we extract a features' pyramid with four levels. Listing 12.3.1 shows features' pyramid extraction from ResNet. conv_layer()
is just a helper function to create a Conv2D(strides=2)-BN-ReLU
layer.
Listing 12.3.1: resnet.py
:
Features' pyramid function:
def features_pyramid(x, n_layers):
"""Generate features pyramid from the output of the
last layer of a backbone network (e.g. ResNetv1 or v2)
Arguments:
x (tensor): Output feature maps of a backbone network...