Semantic segmentation with FCN

Run the following steps to implement semantic segmentation with a pretrained fully convolutional network (FCN) model:

  1. Download the pretrained Caffe FCN model from http://dl.caffe.berkeleyvision.org/fcn8s-heavy-pascal.caffemodel and save it to the models folder. Load the class label names and initialize the legend visualization using the following code block:
lines = open('models/pascal-classes.txt').read().strip().split("\n")classes, colors = [], []for line in lines:   words = line.split(' ')   classes.append(words[0])   colors.append(list(map(int, words[1:])))colors = np.array(colors, dtype="uint8")legend = np.zeros(((len(classes) * 25) + 25, 300, 3), dtype="uint8")# iterate over the class names and colors and ...

Get Python Image Processing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.