Semantic segmentation
Dense prediction, encoder–decoder / FCN, skip connections, upsampling, mIoU — closes the CNN module.
Dense labelling
The topic Object detection located objects with boxes. A box is a coarse answer: a road or the sky has no useful box, and a box around a cyclist contains as much street as cyclist. Segmentation labels every pixel instead. The output has the size of the input, which a classification backbone — built to shrink an image to one vector — cannot produce directly.
Three tasks share the name. Semantic segmentation assigns every pixel a class (two cars become one “car” region). Instance segmentation gives each countable “thing” its own mask. Panoptic segmentation combines both: every pixel gets a class, and things also get an instance id; amorphous “stuff” gets only a class. This topic focuses on the semantic task, the base of the other two.
A patch classifier at every pixel works and is slow: a image needs forward passes, almost all redundant. Key idea: run the network once on the whole image; restore resolution with skips or keep it with dilated convolutions; train with a loss summed over pixels.
Fully convolutional networks
A classification network ends in fully connected layers that fix the input size. A linear layer on a map is exactly a convolution with no padding: the same weighted sum, now sliding. Rewritten this way, the network accepts any size and returns a map of class scores. Fully convolutional networks (FCN, Long, Shelhamer and Darrell, 2015) convert a backbone so and train end to end on per-pixel labels.
A VGG-16 backbone has total stride 32: a input yields a map, each cell standing for a block — blocky if upsampled alone. FCN-32s upsamples that map directly; FCN-16s and FCN-8s add scores from pool4 and pool3 before upsampling. On VOC 2012 test, FCN-8s reached 62.2 mean IoU.
U-Net: encoder, decoder, skips
U-Net (Ronneberger, Fischer and Brox, 2015) gives the upsampling path as much capacity as the downsampling path and passes whole feature maps across. The encoder stacks convolutions and max pools, doubling channels as resolution halves. The decoder mirrors it: upsample (often a transposed convolution with stride 2 — kernel size a multiple of stride, so no checkerboard from Convolution), concatenate the encoder map of the same size, then two convolutions. A final maps each pixel to logits.
The encoder supplies context; the skips supply localization; the decoder learns to combine them. Designed for biomedical images with few labels, U-Net leaned on heavy augmentation and a border-weighted loss. The same shape appears as the noise predictor in diffusion and as the generator in image-to-image GANs.
Dilations and DeepLab
Instead of throwing resolution away and buying it back, dilated (atrous) convolutions keep more of it. Rate reads every -th input: a with spans with nine weights. DeepLab changes a pretrained backbone’s output stride: set a stride-2 layer to stride 1 and double later dilations so that in the receptive-field recursion the product is unchanged. Classification ResNets use stride 32; DeepLabv3 trains at 16 and tests at 8 or 16. Halving output stride multiplies the cost of those stages by 4.
ASPP runs parallel convolutions at several rates (e.g. 6, 12, 18) plus a and image-level pooling, then mixes with another . Logits are bilinearly upsampled to the image. DeepLabv3 reached 85.7% mean IoU on VOC 2012 test with ResNet-101 pretrained on ImageNet then COCO.
Losses: CE and Dice
The default loss is per-pixel cross-entropy
Every pixel weighs the same, so a class that covers 1% of pixels contributes ~1% of the loss. Weight maps (inverse frequency, or U-Net’s border emphasis) help.
The Dice coefficient is pixel F1. Soft Dice loss
does not shrink when the image grows around a fixed object: missing a 4-pixel object costs ~ in both a 100-pixel and a 10{,}000-pixel image, while CE falls from ~ to ~. Dice’s gradient couples all pixels through the denominator, so CE + Dice is a common default.
mIoU and the cost of labels
With confusion counts (true , predicted ),
i.e. per class, then the unweighted mean. Pixel accuracy is dominated by the majority class. In the note’s example, accuracy is and mIoU ; predicting background everywhere scores accuracy but only mIoU. Boundary errors hit small objects hard: a disk of radius 4 predicted one pixel too small has IoU while frame accuracy barely moves.
Mask R-CNN adds a mask head to Faster R-CNN with RoIAlign for fractional alignment — instance masks on top of detection.
This closes the convolutional-networks module: from one convolution layer through backbones and boxes to every pixel. Labels at that density are expensive. The next topic, Self-supervised learning, asks how to learn transferable features with pretext tasks and contrastive losses when dense labels are scarce.
Check your understanding
The same questions as in Pulse. Answers are shared between modes.
Answers are saved on the server and tied to this browser until you sign in.