Scene understanding (semantic segmentation)
In the previous recipe, we focused on one or two specific classes. However, in some cases, you'll want to segment all classes in an image to understand the complete scene. For example, for self-driving cars, it's important that all objects surrounding the car are segmented. In the following recipe, we will segment one class for performance reasons. However, with this network, it is straightforward to scale to multiple classes. The network architecture we will be using is called a fully convolutional network, because we use only convolutional layers in our model. We will be using the pretrained weights of VGG16 and the TensorFlow framework.
How to do it...
- First, we start with loading the libraries, as follows:
import os import glob import tensorflow as tf
- Because our task is slightly more than outputting the predicted class, we need to define a function that extracts the values from different layers:
def extract_layers(vgg_layer3_out, vgg_layer4_out...