Exercise: Download a Pretrained Semantic Segmentation CNN
Apply your knowledge to download a pretrained semantic segmentation CNN, and test it with images of natural scenes.
We'll cover the following
Problem statement
In this exercise, download a pretrained CNN for semantic segmentation. You’ll test the CNN performance with some images of natural scenes and create annotation images showing the found objects.
Launch the Jupyter Notebook below and follow the instructions.
Instructions:
The comment lines starting with
# >>>
indicate that you must edit the cell.Replace the
None
values with the correct function calls.
The main steps that you’ll have to complete are:
Load the pretrained weights of a DeepLabV3 CNN with a MobileNetV3 backbone.
Extract the transformation pipeline and the list of categories from the
weights
object.For each image URL in a list:
Load a PIL image.
Create a batch tensor.
Pass the batch tensor through the CNN.
Extract, for each pixel, the index of the highest logit value.
Convert the index to color in a semantic segmentation image.
Resize the semantic segmentation image to the original size.
Expected output
If everything works like clockwork, you should obtain a pair of images showing the original image and their corresponding semantic segmentation:
Get hands-on with 1400+ tech skills courses.