Instance Segmentation

Machine Learning
Introduced by
He, K., Gkioxari, G., Dollar, P., Girshick, R.
Year
2017
Type
Pixel-level detection and mask prediction
Family
Deep learning / NLP / CV

What does it do?

Instance segmentation is a computer vision task that detects each distinct object in an image and produces a pixel-level mask for each individual object instance.

Unlike semantic segmentation, which assigns a class to every pixel, it separates objects of the same class from one another. The task covers only countable object categories ("things"); amorphous background regions ("stuff") are not labelled by instance segmentation. Panoptic segmentation is a related but different task that labels both things and stuff. Instance segmentation makes it possible to count and delineate individual objects.

The intuition behind the method

Consider a photograph of a crowd. Semantic segmentation would give every person the same colour, whereas instance segmentation gives each person a separate outline and mask. The task combines object detection, which locates things, with mask prediction, which determines exactly which pixels belong to each thing. It is therefore suited to tasks that require counting, measuring or tracking individual objects, not only classifying image regions.

History

Mask R-CNN was introduced by He, Gkioxari, Dollár and Girshick at ICCV in 2017. It extends Faster R-CNN with a parallel branch that predicts an object mask alongside the bounding-box output. The authors report top results on the COCO instance segmentation, bounding-box detection and person keypoint detection tracks, and hope the approach will serve as a solid baseline for later work in instance-level recognition.

When to use it

Choose instance segmentation when you must identify, count and delineate individual objects in images, especially when objects of the same class overlap or touch and need to be told apart, such as cells in microscopy, vehicles in aerial imagery or people in surveillance footage. It requires per-pixel mask annotations for training, so it is a poor choice when only bounding boxes are available. Do not use it when only class-level regions are needed, since semantic segmentation is simpler and cheaper, and do not rely on the standard two-stage design when real-time inference on constrained hardware is required without model optimisation.

Limitations and considerations

  • Training requires per-pixel mask annotations, which are costly to produce compared with bounding boxes.
  • The mask head predicts a small fixed-resolution mask (for example 28x28) that is resized to the box, which limits boundary detail for objects that are small or have intricate outlines.
  • Standard Mask R-CNN is computationally heavy, so real-time performance on ordinary hardware generally requires lighter architectures or optimisation.
  • Heavily occluded or very small objects give ambiguous boundaries, which degrades mask quality.
  • Training from scratch needs a large annotated set; with too little data the masks are typically of poor quality.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • A single network produces bounding boxes, class labels and pixel masks for each detected object.
  • Because each object receives its own mask, individual instances of the same class can be counted and measured.
  • Mask R-CNN extends Faster R-CNN with a separate mask branch, so the mask head adds relatively little overhead to the detector, according to the original abstract.
  • Models pre-trained on COCO can be fine-tuned to new domains with a moderate amount of labelled data.
  • Established open-source implementations, such as Detectron2, MMDetection and Ultralytics, provide training pipelines for this model family.

Applications

  • Medical image analysis: segmenting individual cells, tumours, or organs in histology and radiology scans.
  • Autonomous driving: delineating pedestrians, cyclists, and vehicles for path planning.
  • Agricultural monitoring: counting and measuring individual plants, fruits, or lesions from drone imagery.
  • Industrial quality control: detecting and isolating defective parts on production lines.
  • Robotics: enabling manipulation systems to grasp specific objects in cluttered scenes.
  • Satellite and aerial imagery: mapping individual buildings, vehicles, or land parcels.

How it works

How it works

1

A deep convolutional backbone, typically a ResNet combined with a Feature Pyramid Network, extracts feature maps at several scales from the input image. These maps combine fine texture information with higher-level semantic information, which supports detection of objects of different sizes.

2

A Region Proposal Network (RPN) scans the feature maps and proposes candidate bounding boxes, called regions of interest, that may contain objects. Each proposal receives an objectness score, and only the higher-scoring proposals are passed to the later stages, which reduces computation on background areas.

3

For each proposed region, RoI Align extracts a fixed-size feature map using bilinear interpolation at sampled points instead of rounding coordinates to the feature grid, as RoI Pooling does. Avoiding this rounding keeps the features spatially aligned with the image, which matters because the mask head depends on precise spatial detail.

4

Three prediction heads operate in parallel on each RoI feature: a classification head that assigns a class label, a bounding-box regression head that refines the box coordinates, and a mask head that predicts a binary mask. Training optimises the three losses jointly.

5

The mask head predicts a small binary mask per class for each candidate instance, for example 28x28 pixels. Because the mask branch runs in parallel with the box branch, mask prediction is decoupled from classification: the mask loss is applied only to the mask of the ground-truth class. At inference the mask for the predicted class is resized to the bounding-box dimensions and thresholded, and the resulting pixel mask is overlaid on the original image.

Common pitfalls

  • Supplying bounding-box-only annotations when the model needs mask ground truth, since the mask branch cannot learn segmentation without masks.
  • Leaving the confidence and non-maximum suppression (NMS) thresholds untuned, which can produce duplicate or missing detections of the same object.
  • Reporting only bounding-box AP instead of mask AP (AP_mask), which measures the segmentation quality the task requires.
  • Ignoring class imbalance across object categories, which can leave rare classes poorly segmented.
  • Fine-tuning only the head layers when the target domain differs strongly from the pre-training data, which can yield weak feature representations.

Frequently asked questions

What is the difference between instance segmentation and semantic segmentation?

Semantic segmentation assigns a class label to every pixel but does not distinguish between separate objects of the same class, so all cars receive the same colour. Instance segmentation treats each individual object as a separate entity, so two overlapping cars receive two distinct masks.

How much annotated data do I need?

The answer depends on the number of classes, the variability of the images and how closely the target domain matches the pre-training data. Fine-tuning a COCO-pretrained model generally needs far less data than training from scratch, which requires a large annotated set. Pilot training on a subset of your data is a practical way to estimate the requirement. Annotation software that supports polygon and mask labelling can reduce the cost of producing masks.

Which metric should I report?

The standard metric is mask Average Precision (AP_mask), computed at multiple IoU thresholds (typically 0.50:0.95) following the COCO evaluation protocol. Report AP_mask rather than only bounding-box AP, and include AP at IoU 0.50 and 0.75 for completeness.

Can instance segmentation run in real time?

The original Mask R-CNN paper reports a speed of about 5 fps, which is too slow for most real-time video applications. Lighter single-stage designs are built for faster inference, usually at some cost in accuracy. Model quantisation and TensorRT optimisation can further speed up inference on embedded hardware. Measure throughput on your own hardware and input resolution, since reported speeds depend on those settings.

Is instance segmentation suitable for very small objects?

Small-object performance is difficult. Using high-resolution inputs, FPN multi-scale features and evaluation on the COCO small-object subset (AP_S) helps diagnose the problem. Specialised architectures or tiling strategies may be needed for domains such as satellite imagery with densely packed small objects.

Related methods

Sources

  1. He, K., Gkioxari, G., Dollar, P., & Girshick, R. (2017). Mask R-CNN. Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2961–2969.

    Open DOI reference
  2. Instance segmentation. Wikipedia.

    Open publication reference
  3. 02_1a09b8d7946bb61deffe21cdd453b2c53cdd1634, p. 3