CInstanceSegmentationIO

class ikomia.dataprocess.pydataprocess.CInstanceSegmentationIO

Define input or output managing common information extracted by instance segmentation task. Such task are able to automatically detect objects and their shapes in image. It gets class label, confidence, bounding box and mask for each one. For each object, information is stored in a CInstanceSegmentation instance. Among others, algorithms like MaskRCNN, Yolact, SparseInst are instance segmentation tasks.

Import

from ikomia.dataprocess import CInstanceSegmentationIO

Methods

__init__(arg1)

__init__( (object)self) -> None :

add_object(self, id, type, class_index, ...)

Add segmented instance to the input/output.

get_object_count(self)

Get the number of segmented instances.

get_object(self, index)

Get segmented instance information at a given index.

get_objects(self)

Get all segmented instances.

get_merge_mask(self)

Get an image array where all segmented masks are merged into a single grayscale mask: one graylevel value for each class.

init(self, task_name, ref_image_index, ...)

Initialisation step to set associated task (name), reference image and mask size.

Overridden methods

clear_data(self)

See clear_data().

is_data_available(self)

See is_data_available().

load(self, path)

Load instance segmentation input/output for JSON file.

save(self, path)

Save instance segmentation input/output to JSON file.

to_json(self)

Return input/output data in JSON formatted string (compact mode and image encoded as JPEG).

from_json(self, json_str)

Set input/output data from JSON formatted string.

Inherited methods

copy_static_data(self, io)

Copy the static data from the given input or ouput.

get_unit_element_count(self)

Get the number of unit elements in terms of processing scheme.

Attributes

auto_save

Auto-save status

data_type

I/O data type

dim_count

Number of dimensions

description

Custom description to explain input/output type and use

displayable

Displayable status (Ikomia Studio)

name

I/O name

source_file_path

Path to the source file used as workflow input (if any)

Details

__init__((object)arg1) None
__init__( (object)self) -> None :

Default constructor

__init__( (object)arg1, (CInstanceSegmentationIO)arg2) -> None :

Copy constructor

add_object((CInstanceSegmentationIO)self, (int)id, (int)type, (int)class_index, (str)label, (float)confidence, (float)box_x, (float)box_y, (float)box_width, (float)box_height, (object)mask, (object)color) None :

Add segmented instance to the input/output.

Parameters:
  • id (int) – instance identifier

  • type (int) – segmentation instance type (0:THING - 1:STUFF)

  • classIndex (int) – index of the associated class

  • label (str) – class label

  • confidence (double) – prediction confidence

  • boxX (double) – left coordinate of object bounding box

  • boxY (double) – top coordinate of object bounding box

  • boxWidth (double) – width of object bounding box

  • boxHeight (double) – height of object bounding box

  • mask (numpy array) – binary mask

  • color (int list - rgba) – display color

clear_data((CInstanceSegmentationIO)self) None :

See clear_data().

clear_data( (CInstanceSegmentationIO)self) -> None

get_object_count((CInstanceSegmentationIO)self) int :

Get the number of segmented instances.

Returns:

object count

Return type:

int

get_object((CInstanceSegmentationIO)self, (int)index) CInstanceSegmentation :

Get segmented instance information at a given index.

Parameters:

index (int) – object index

Returns:

segmented instance information

Return type:

CInstanceSegmentation

get_objects((CInstanceSegmentationIO)self) object :

Get all segmented instances.

Returns:

segmented instances

Return type:

CInstanceSegmentation list

get_merge_mask((CInstanceSegmentationIO)self) object :

Get an image array where all segmented masks are merged into a single grayscale mask: one graylevel value for each class. This image output is typically used for display, Ikomia Studio uses it to create an overlay color mask on top of the reference image.

Returns:

grayscale mask

Return type:

2D numpy array (uint8)

init((CInstanceSegmentationIO)self, (str)task_name, (int)ref_image_index, (int)width, (int)heigh) None :

Initialisation step to set associated task (name), reference image and mask size. The reference image is the task output index where the graphics information (label, box) will be displayed as an overlay layer.

Parameters:
  • taskName (str) – task that contains the output

  • refImageIndex (int) – zero-based index of the output containing the reference image

  • width (int) – mask width

  • height (int) – mask height

is_data_available((CInstanceSegmentationIO)self) bool :

See is_data_available().

is_data_available( (CInstanceSegmentationIO)self) -> bool

load((CInstanceSegmentationIO)self, (str)path) None :

Load instance segmentation input/output for JSON file.

Args:

path (str): path to JSON file

load( (CInstanceSegmentationIO)self, (str)path) -> None

save((CInstanceSegmentationIO)self, (str)path) None :

Save instance segmentation input/output to JSON file.

Args:

path (str): path to JSON file

save( (CInstanceSegmentationIO)self, (str)path) -> None

to_json((CInstanceSegmentationIO)self) str :
Return input/output data in JSON formatted string (compact mode and image encoded as JPEG).

Returns:

string: JSON formatted string

to_json( (CInstanceSegmentationIO)self) -> str

to_json( (CInstanceSegmentationIO)self, (object)options) -> str :

Return input/output data in JSON formatted string. JSON format options can be set, possible values are:

  • [‘json_format’, ‘compact’] (default)

  • [‘json_format’, ‘indented’]

  • [‘image_format’, ‘jpg’](for the mask - default)

  • [‘image_format’, ‘png’]

Args:

list of str: format-specific options encoded as pairs [option_name, option_value]

Returns:

string: JSON formatted string

to_json( (CInstanceSegmentationIO)self, (object)options) -> str

from_json((CInstanceSegmentationIO)self, (str)json_str) None :

Set input/output data from JSON formatted string.

Args:

str: data as JSON formatted string

from_json( (CInstanceSegmentationIO)self, (str)json_str) -> None