Run the following steps to implement semantic segmentation with a pretrained fully convolutional network (FCN) model:
- 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 ...