In this section, we'll leverage the U-Net architecture to predict the class that corresponds to all the pixels in the image. A sample of such an input-output combination is as follows:
Note that, in the preceding picture, the objects that belong to the same class (in the left image – the input image) have the same pixel value (in the right image – the output image), which is why we are segmenting the pixels that are semantically similar to each other. This is also known as semantic segmentation.
Now, let's learn how to code semantic segmentation:
The following code is available as Semantic_Segmentation_with_U_Net.ipynb in the Chapter09 folder of this book's GitHub repository - https://tinyurl.com/mcvp-packt The code contains URLs to download data from and is moderately lengthy.
- Let's begin by downloading the necessary datasets, installing the necessary packages, and then importing them. Once we've...