Semantic segmentation (U-Net)

How a U-Net Gives Every Pixel of a Street Scene a Class: Semantic Segmentation

Semantic segmentation with a U-Net, from pixel through encoder and decoder to a class for every pixel.

Semantic segmentation assigns a class to every pixel rather than a single class to the whole image. This page works through a trained U-Net with 69,394 parameters on street scenes. You pick a spot in the image and see in matrices of numbers how pixel values turn, layer by layer, into the class background, car, truck, or bus.

U-Net · trained 69,394 parameters 4 classes Skip connections Encoder and decoder

Choose a scene at the top. Click in the image to set the spot whose numbers the matrices show. Press “Play” and the computation runs by itself, or use the step list to jump to any point.

All computations run in your browser. Teaching example, not a production forecast.

What the Walkthrough Shows and Where It Ends

The network is a U-Net that halves the resolution four times. The downsampling part is called the encoder. Five convolutional layers condense the image there, and before four of them max pooling halves width and height. The decoder enlarges the result again in four steps and joins it at each stage with the encoder maps of the same size. This joining is called a skip connection. It gives the network back the spatial precision that was lost in pooling. Your browser carries out the calculation steps on this page with the trained weights.

The network was trained with PyTorch in 20,000 steps on 888 scenes. The masks, that is, the areas of the vehicles pixel by pixel, come from the predictions of a large detection network, which were cleaned up after a review. On this page, they are called the label. No human drew the masks. Vans count as trucks, and pickups count as cars.

The measurement used 84 additional scenes that were held out of every training run. On those scenes, the overlap (IoU) between the vehicle area and the label is 82.8%. Per vehicle class, the value is lower, at 77.9% for cars, 61.3% for trucks, and 66.5% for buses. The metrics are slightly optimistic because the network shown was selected from three candidates after the measurement. The eight scenes on this page were selected because the network covers most of every vehicle there and assigns it the correct class.

This page is a teaching example, not a production system. The network does not separate individual vehicles. Two cars side by side receive the same class and are not counted. Only synthetically generated street scenes seen at an oblique angle have been tested. The measurement does not apply to photos from the real world, to vertical top-down views, or to other vehicle types. The object detection walkthrough shows how a network finds individual vehicles with boxes. The CNN walkthrough applies the same design in a smaller form to images of model cars. There, the network distinguishes only car and background, and individual objects are derived from the mask.