Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

Deep Learning for Computer Vision · Lecture 11 of 16 · 1:14:26

Lecture 11: Detection and Segmentation

Lecture 11 | Detection and Segmentation on YouTube

Study guide

What this lecture covers

Up to this point the course has treated computer vision as image classification: one label per image. This lecture asks a broader question: how do you get a convolutional network to say something about where things are, not just what they are? It works through four increasingly detailed tasks - semantic segmentation, classification plus localization, object detection, and instance segmentation - showing how each one reuses the classification machinery already built up in the course, with new architectural pieces bolted on.

By the end you should be able to describe how a fully convolutional network produces a per-pixel label map, explain what a transpose convolution actually computes, and trace the evolution from R-CNN through Fast R-CNN and Faster R-CNN to single-shot detectors like YOLO and SSD, ending with Mask R-CNN as a model that unifies detection, segmentation, and pose estimation in one network.

Key ideas

  • Semantic segmentation: label every pixel of an image with a category, without distinguishing between separate instances of the same class.
  • Fully convolutional network: a stack of convolutional layers with no fully-connected layers, trained with a cross-entropy loss averaged over every output pixel.
  • Downsampling and upsampling: efficient segmentation networks shrink the feature map with pooling or strided convolution, then grow it back with unpooling or transpose convolution rather than staying at full resolution throughout.
  • Transpose convolution: a learnable upsampling operation where each input value weights a copy of the filter that gets placed (and summed where it overlaps) into the output; also called deconvolution, upconvolution, or fractionally strided convolution.
  • Classification plus localization: predicts a class label and, separately, four numbers for a bounding box, trained with a weighted multi-task loss combining softmax and a regression loss (L2 or similar).
  • Object detection: unlike localization, the number of objects per image is unknown in advance, so the problem cannot be framed as fixed-size regression.
  • Region proposals and the R-CNN family: R-CNN, Fast R-CNN, and Faster R-CNN progressively move more of the pipeline (feature sharing, then region proposal generation itself) inside the network to cut cost.
  • Single-shot detectors (YOLO, SSD): predict boxes and classes for a grid of base boxes in one forward pass, trading some accuracy for speed against region-based methods.

Walkthrough

Semantic segmentation: from sliding windows to fully convolutional networks (11:16)

The lecture opens the segmentation problem by first describing a naive sliding-window approach: classify the center pixel of every small crop in the image. This is rejected immediately as computationally prohibitive, since neighboring crops share most of their pixels and redundantly repeat convolution work. The alternative is a fully convolutional network that keeps spatial dimensions constant through a stack of convolutions and outputs a tensor of class scores for every pixel at once, trained with cross-entropy loss summed or averaged over all pixels and the batch. Running every layer at full input resolution is itself expensive, which motivates the next section.

Upsampling: unpooling and transpose convolution (19:46)

Practical segmentation networks downsample early (via pooling or strided convolution) and upsample later, keeping most layers at low resolution. The lecture covers three fixed (non-learned) upsampling strategies - nearest neighbor unpooling, bed-of-nails unpooling, and max unpooling, which reuses the positions recorded during the matching max-pooling step - before introducing transpose convolution as a learnable alternative. It walks through the 1D matrix-multiplication view of ordinary convolution and shows that transpose convolution corresponds to multiplying by the transpose of that same weight matrix, which is also mathematically identical to the backward pass of ordinary convolution. A stride-two transpose convolution with a 3x3 kernel can produce checkerboard artifacts because overlapping output regions are summed unevenly; using a 4x4 or 2x2 kernel instead reduces this problem.

Classification plus localization and pose estimation (32:45)

Here the network keeps the classification head but adds a second fully-connected branch predicting four numbers for a single bounding box, assuming exactly one object per image. Training uses a multi-task loss: softmax loss for the class, plus a regression loss (typically L2) between predicted and ground-truth box coordinates, combined with a hyperparameter weight. The lecture notes that this weight is unusually hard to tune by comparing loss values, because it changes the loss itself, so cross-validation should instead track a separate performance metric. The same fixed-output-count idea extends to human pose estimation, where the network regresses the (x, y) coordinates of a fixed number of body joints (for example 14) using a regression loss rather than cross-entropy.

Object detection: region proposals and the R-CNN family (45:40)

Object detection differs from localization because the number of objects per image is unknown, ruling out fixed-size regression. A brute-force sliding-window classifier (with an added "background" category) is again shown to be intractable given the number of possible crop positions, sizes, and aspect ratios. The fix is region proposals: traditional (non-learned) algorithms like Selective Search that generate roughly 2,000 candidate boxes per image. R-CNN classifies each warped proposal crop independently and regresses a correction to its box, but is extremely slow to train and run because every proposal passes through the full network separately. Fast R-CNN fixes this by running the whole image through convolutional layers once and cropping from the resulting feature map using an ROI pooling layer, cutting training time roughly tenfold and shifting the remaining bottleneck to computing the region proposals themselves.

Faster R-CNN, single-shot detectors, and instance segmentation (58:01)

Faster R-CNN removes the external region-proposal bottleneck by adding a region proposal network inside the model that shares the same convolutional features, producing a four-way multi-task loss (proposal objectness, proposal box regression, final classification, final box regression). The lecture then contrasts this region-based family with single-shot detectors, YOLO and SSD, which divide the image into a grid, assign a set of base boxes per cell, and regress offsets and class scores for all of them in a single pass - faster but generally less accurate than Faster R-CNN. It briefly mentions dense captioning as a related idea that swaps the classification head for an RNN language model. The lecture closes with instance segmentation, where Mask R-CNN extends Faster R-CNN with an extra branch that predicts a per-pixel segmentation mask for each detected region, and shows this same architecture can also add a branch for pose estimation, unifying detection, segmentation, and pose in one jointly trained network.

Before you watch

  • Be comfortable with the CNN classification pipeline (convolution, pooling, fully-connected output, softmax and cross-entropy loss) from earlier lectures in this course.
  • Know what a multi-task loss is and why combining two loss terms with a weighting hyperparameter is different from tuning an ordinary hyperparameter.
  • Some familiarity with recurrent networks (image captioning) is useful for the brief dense captioning aside, but not required for the main content.

Check your understanding

  1. Why is a naive sliding-window classifier impractical for both semantic segmentation and object detection, and what problem do region proposals or fully convolutional networks solve instead?
  2. Explain what a transpose convolution computes and why summing overlapping regions can differ from what plain upsampling would give you.
  3. What are the two loss terms in a classification-plus-localization network, and why is their relative weighting harder to tune than a typical hyperparameter?
  4. Walk through what changes at each step from R-CNN to Fast R-CNN to Faster R-CNN, and what specifically each step speeds up.
  5. How does Mask R-CNN extend Faster R-CNN to perform instance segmentation and pose estimation?

Vocabulary

semantic segmentation (noun)
The task of labeling every pixel of an image with a category.
Semantic segmentation labels each pixel as sky, road, or car.
instance (noun)
A single, individual example of an object or category.
Instance segmentation separates different instances of the same class.
fully convolutional network (noun)
A network made entirely of convolutional layers, with no fully connected layers.
A fully convolutional network outputs a label for every pixel.
cross-entropy loss (noun)
A loss function commonly used for classification that measures the difference between predicted and true probabilities.
Segmentation is trained with cross-entropy loss per pixel.
downsample (verb)
To reduce the spatial size or resolution of data.
The network downsamples the feature map before upsampling it.
upsample (verb)
To increase the spatial size or resolution of data.
The network upsamples the feature map to full resolution.
unpooling (noun)
A fixed method for increasing the spatial size of a feature map.
Max unpooling reuses positions recorded during pooling.
transpose convolution (noun)
A learnable operation that upsamples a feature map using a trained filter.
Transpose convolution learns how to upsample rather than using a fixed rule.
checkerboard artifact (noun)
An unwanted repeating pattern that can appear from certain upsampling operations.
A 3x3 transpose convolution can create checkerboard artifacts.
bounding box (noun)
A rectangle marking the location of an object in an image.
The model predicts four numbers for the bounding box.
multi-task loss (noun)
A loss combining several objectives, each contributing to the total error.
Classification and localization are trained with a multi-task loss.
regression loss (noun)
A loss function used to predict continuous numerical values.
Bounding box coordinates are trained with a regression loss.
ground-truth (adjective)
Referring to the correct, true answer used for training or evaluation.
The predicted box is compared to the ground-truth box.
region proposal (noun)
A candidate area in an image that might contain an object.
Region proposals suggest where objects might be located.
intractable (adjective)
Too difficult or resource-intensive to solve in practice.
Brute-force sliding-window detection is intractable for large images.
warp (image) (verb)
To resize or reshape an image region to a fixed size.
R-CNN warps each proposal crop before classifying it.
feature map (noun)
The output produced by a convolutional layer, representing learned patterns.
Fast R-CNN crops regions from a shared feature map.
ROI pooling (noun)
A technique that extracts a fixed-size feature from a region of interest.
ROI pooling lets Fast R-CNN share computation across proposals.
objectness (noun)
A score indicating how likely a region is to contain any object at all.
The region proposal network predicts an objectness score.
single-shot detector (noun)
A detection method that predicts all boxes and classes in one forward pass.
YOLO and SSD are examples of single-shot detectors.
grid cell (noun)
One section of an image divided into a regular grid for detection.
Each grid cell predicts boxes and class scores.
dense captioning (noun)
A task that generates a text description for each detected region in an image.
Dense captioning combines detection with language generation.
instance segmentation (noun)
The task of detecting objects and outlining each one at the pixel level separately.
Mask R-CNN performs instance segmentation on detected objects.
segmentation mask (noun)
A pixel-level map showing exactly which pixels belong to an object.
Mask R-CNN predicts a segmentation mask for each detected region.

Chapters

From the YouTube description

In Lecture 11 we move beyond image classification, and show how convolutional networks can be applied to other core computer vision tasks. We show how fully convolutional networks equipped with downsampling and upsampling layers can be used for semantic segmentation, and how multitask losses can be used for localization and pose estimation. We discuss a number of methods for object detection, including the region-based R-CNN family of methods and single-shot methods like SSD and YOLO. Finally we show how ideas from semantic segmentation and object detection can be combined to perform instance segmentation.

Keywords: Semantic segmentation, fully convolutional networks, unpooling, transpose convolution, localization, multitask losses, pose estimation, object detection, sliding window, region proposals, R-CNN, Fast R-CNN, Faster R-CNN, YOLO, SSD, DenseCap, instance segmentation, Mask R-CNN

Slides: http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture11.pdf

--------------------------------------------------------------------------------------

Convolutional Neural Networks for Visual Recognition

Instructors:
Fei-Fei Li: http://vision.stanford.edu/feifeili/
Justin Johnson: http://cs.stanford.edu/people/jcjohns/
Serena Yeung: http://ai.stanford.edu/~syyeung/

Computer Vision has become ubiquitous in our society, with applications in search, image understanding, apps, mapping, medicine, drones, and self-driving cars. Core to many of these applications are visual recognition tasks such as image classification, localization and detection. Recent developments in neural network (aka “deep learning”) approaches have greatly advanced the performance of these state-of-the-art visual recognition systems. This lecture collection is a deep dive into details of the deep learning architectures with a focus on learning end-to-end models for these tasks, particularly image classification. From this lecture collection, students will learn to implement, train and debug their own neural networks and gain a detailed understanding of cutting-edge research in computer vision.

Website:
http://cs231n.stanford.edu/

For additional learning opportunities please visit:
http://online.stanford.edu/

← Lecture 10: Recurrent Neural Networks · Lecture 12: Visualizing and Understanding →