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
| Level | Task | Output |
|---|---|---|
| Classification | What is in the image? | Class label |
| Object Detection | Where are the objects? | Bounding boxes + labels |
| Semantic Segmentation | Pixel-wise classification | Class label per pixel |
| Instance Segmentation | Pixel-wise + distinguish instances | Mask per object instance |
R-CNN (Region-based CNN)
- Generate ~2000 region proposals using Selective Search
- Warp each region to fixed size
- Extract features using a CNN (e.g., AlexNet) — see 8. Convolutional Neural Networks
- Classify each region with an SVM
- 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.
- Generate region proposals with Selective Search
- Run entire image through CNN → feature map
- For each proposal, extract features via RoI (Region of Interest) Pooling
- 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:
- Backbone CNN → shared feature map
- RPN → generates proposals from the feature map
- RoI Pooling → extracts fixed-size features for each proposal
- 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.