Object Detection and Segmentation

Related: 8. Convolutional Neural Networks | 9. CNNs Part II — Improving Generalisability | 10. Transfer Learning and Pre-trained CNNs | Artificial Intelligence


Computer Vision Task Hierarchy

LevelTaskOutput
ClassificationWhat is in the image?Class label
Object DetectionWhere are the objects?Bounding boxes + labels
Semantic SegmentationPixel-wise classificationClass label per pixel
Instance SegmentationPixel-wise + distinguish instancesMask per object instance

R-CNN (Region-based CNN)

  1. Generate ~2000 region proposals using Selective Search
  2. Warp each region to fixed size
  3. Extract features using a CNN (e.g., AlexNet) — see 8. Convolutional Neural Networks
  4. Classify each region with an SVM
  5. Refine bounding boxes with regression

Cons: Very slow — requires ~2000 CNN forward passes per image.

Fast R-CNN

Key improvement: Run the CNN only once per image to produce a shared feature map.

  1. Generate region proposals with Selective Search
  2. Run entire image through CNN → feature map
  3. For each proposal, extract features via RoI (Region of Interest) Pooling
  4. Classify and refine bounding boxes in one unified network

Con: Still uses slow Selective Search for proposals.

Faster R-CNN

Replaces Selective Search with a Region Proposal Network (RPN) — a small CNN that generates proposals from the feature map itself.

Architecture:

  1. Backbone CNN → shared feature map
  2. RPN → generates proposals from the feature map
  3. RoI Pooling → extracts fixed-size features for each proposal
  4. Classification head → classifies and refines boxes

Everything is end-to-end trainable.

U-Net (Semantic Segmentation)

An encoder-decoder architecture with skip connections between corresponding encoder and decoder layers. Structurally similar to 12. Autoencoders but with skip connections that preserve spatial detail.

  • Encoder (downsampling path): extracts context using Conv + MaxPool
  • Decoder (upsampling path): restores spatial resolution
  • Skip connections: combine location information from the encoder with context from the decoder

Advantages: No dense layers (input can be any size), combines localisation and context.

Mask R-CNN (Instance Segmentation)

Extends Faster R-CNN by adding a mask branch that outputs a binary segmentation mask for each detected object, providing pixel-level segmentation alongside bounding boxes and class labels.