For the complete documentation index, see llms.txt. This page is also available as Markdown.

rleinstancesegmentationprediction Kind

Prediction with detected bounding boxes and RLE-encoded segmentation masks in form of sv.Detections(...) object.

Prediction with detected bounding boxes and RLE-encoded segmentation masks in form of sv.Detections(...) object

This kind represents an instance segmentation prediction whose masks are stored with RLE (Run-Length Encoding) instead of decoded numpy arrays. The masks live in sv.Detections.data["rle_masks"] as a numpy array of RLE dictionaries in COCO format: {"size": [H, W], "counts": "encoded_string"}.

When visualization blocks need numpy masks, they decode the RLE on demand using pycocotools.

Example internal value:

sv.Detections(
    xyxy=array([[        127,         189,         322,         303]]),
    mask=None,  # Initially None, populated lazily when needed
    confidence=array([    0.95898]),
    class_id=array([6]),
    tracker_id=None,
    data={
        'class_name': array(['person'], dtype='<U6'),
        'detection_id': array(['51dfa8d5-261c-4dcb-ab30-9aafe9b52379'], dtype='<U36'),
        'parent_id': array(['image.[0]'], dtype='<U9'),
        'image_dimensions': array([[425, 640]]),
        'prediction_type': array(['rle-instance-segmentation'], dtype='<U26'),
        'rle_masks': array([{'size': [425, 640], 'counts': 'encoded_rle_string'}], dtype=object),
        # ... other standard fields
    }
)

Data representation

External

External data representation is relevant for Workflows clients - it dictates what is the input and output format of data.

Type: dict

Serialised entity details are similar to instance_segmentation_prediction, but with RLE masks instead of polygons. The RLE format follows the COCO standard and can be decoded with pycocotools.mask.decode().

Internal

Internal data representation is relevant for Workflows blocks creators - this is the type that will be provided by Execution Engine in runtime to the block that consumes input of this kind.

Type: sv.Detections

Last updated

Was this helpful?