Instance segmentation

Instance segmentation finds each object of the known classes and outlines it with its own pixel mask, so two touching cars come out as two masks with two identities rather than one region labeled car. In Supervisely, Detectron2, MMDetection and YOLO segmentation models train on polygons and bitmap masks.

Tasks and trainingAlso called Instance vs semantic segmentation

Instance, semantic and panoptic

InstanceSemanticPanoptic
Question it answersWhich objects, and exactly where?Which class is each pixel?Both, for every pixel
Separate objectsYesNoYes, for countable classes
Every pixel labeledNo, only objectsYesYes

Choose instance segmentation when you need to count, measure or track individual objects; choose semantic segmentation when only the area of each class matters, such as road versus sidewalk. Panoptic segmentation combines the two.

How the models work

The classic design adds a mask branch to a two-stage detector: Mask R-CNN predicts a box for each object, then a small mask inside it. Detectron2 ships Mask R-CNN baselines, MMDetection covers many more architectures, and YOLO has segmentation variants that predict masks in a single stage.

Labels to prepare

Each object needs its own polygon or bitmap, with a class. A box is not enough. Polygon annotation is the usual choice; bitmaps suit hair-thin or ragged edges.

Pitfalls

  • One polygon drawn around two touching objects, which teaches the model to merge them.
  • An occluded object split in two by a pole, labeled as two objects instead of one object with two parts.
  • Masks that overlap their neighbours, so the same pixel belongs to both.

In Supervisely

The Smart Tool in the image labeling tool returns a mask from a box, and polygons of touching objects share one border. Detectron2, MMDetection 3.0 and YOLO segmentation models train on polygons and bitmaps, and their evaluation report uses the detection metrics with IoU measured between masks.

Frequently asked questions.

What is the difference between instance, semantic and panoptic segmentation?

Semantic segmentation gives every pixel a class; instance segmentation gives each object its own mask, so two cars are two masks; panoptic segmentation does both, labeling countable objects as instances and background regions such as sky or road by class.

Which models do instance segmentation?

Mask R-CNN in Detectron2, YOLO segmentation models in Ultralytics YOLO, SparseInst and models from MMDetection are common choices that train in Supervisely.