class documentation

class InstanceSegmentationAnnotation(SegmentationAnnotation):

View In Hierarchy

Instance segmentation annotation.

Subclass of SegmentationAnnotation used to distinguish instance segmentation annotations from semantic segmentation annotations.

The array representation of a single instance segmentation annotation is the same as that of a semantic segmentation annotation, but multiple instance segmentation annotations are combined into an array of shape (N, H, W) where the leading dimension N corresponds to the number of instance annotations instead of the number of classes as in semantic segmentation.

Static Method combine_to_numpy Combine instance segmentation annotations into instance masks.

Inherited from SegmentationAnnotation:

Method to_numpy Convert the segmentation annotation to a binary mask.
Instance Variable counts Run-length encoded mask data.
Instance Variable height The height of the segmentation mask.
Instance Variable width The width of the segmentation mask.
Class Method _validate_mask Undocumented
Class Method _validate_polyline Undocumented
Class Method _validate_rle Undocumented
Static Method _clip_points Undocumented
Static Method _numpy_to_rle Undocumented
Method _serialize_counts Undocumented
@staticmethod
@override
def combine_to_numpy(annotations: list[InstanceSegmentationAnnotation], classes: list[int] | None = None, n_classes: int | None = None) -> np.ndarray:

Combine instance segmentation annotations into instance masks.

Note

As opposed to semantic segmentation, overlapping annotations are allowed and are not resolved in any way. One pixel can belong to multiple instances and will be marked as 1 in each instance mask it belongs to.

Parameters
annotations:list[InstanceSegmentationAnnotation]Instance segmentation annotations to combine.
classes:list[int] | NoneUnused class IDs kept for API compatibility.
n_classes:int | NoneUnused class count kept for API compatibility.
Returns
np.ndarrayCombined instance segmentation masks of shape (N, H, W) where N is the number of instances.