Docs /Templates/ sinapsis-data-visualization

SegmentationMaskDrawer

sinapsis-data-visualizationcommunityannotationsdrawerimagevisualization

Python template · sinapsis_data_visualization.templates.segmentation_mask_drawer

Overview

A class for drawing segmentation masks and keypoints on images, extending from BBoxDrawer.

This class allows drawing segmentation masks (binary or RGB masks) along with keypoints on images. It inherits from the `BBoxDrawer` class to reuse its functionality for drawing bounding boxes and adds the ability to handle segmentation masks, which can be overlaid with specific transparency levels (alpha).

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-data-visualization==1.0.0
uv pip install sinapsis-data-visualization==1.0.0
uv add sinapsis-data-visualization==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

alpha
float
Optional
Default: 0.5
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
overwrite
bool
Optional
Default: false
text_style
TextStyle
Optional
Default: null
font

Style of font Available options: FONT_HERSHEY_SIMPLEX = 0. FONT_HERSHEY_PLAIN = 1. FONT_HERSHEY_DUPLEX = 2. FONT_HERSHEY_COMPLEX = 3. FONT_HERSHEY_TRIPLEX = 4. FONT_HERSHEY_COMPLEX_SMALL = 5. FONT_HERSHEY_SCRIPT_SIMPLEX = 6. FONT_HERSHEY_SCRIPT_COMPLEX = 7.

int
Optional
Default: 0
thickness

Thickness of font

int
Optional
Default: 2
font_scale

Scale of font

float
Optional
Default: 0.5
draw_confidence
bool
Optional
Default: true
randomized_color
bool
Optional
Default: true
draw_extra_labels
bool
Optional
Default: true
draw_classification_label
bool
Optional
Default: false
text_box_to_border_offset
float
Optional
Default: 0.01
classification_label_position
typing.Literal['top_left', 'top_right']
Optional
Default: "top_right"

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: SegmentationMaskDrawer
  class_name: SegmentationMaskDrawer
  template_input: InputTemplate
  attributes:
    overwrite: false
    randomized_color: true
    draw_confidence: true
    draw_extra_labels: true
    text_style:
      font: 0
      font_scale: 0.5
      thickness: 2
    draw_classification_label: false
    classification_label_position: top_right
    text_box_to_border_offset: 0.01
    alpha: 0.5
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "SegmentationMaskDrawer"
    class_name: "SegmentationMaskDrawer"
    attributes:
      alpha: 0.5
      overwrite: false
      text_style:
        font: 0
        thickness: 2
        font_scale: 0.5
      draw_confidence: true
      randomized_color: true
      draw_extra_labels: true
      draw_classification_label: false
      text_box_to_border_offset: 0.01
      classification_label_position: "top_right"

Inheritance

Immediate parent: sinapsis_data_visualization.templates.bbox_drawer.BBoxDrawer

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.