CSemanticSegmentationIO¶
- class ikomia.dataprocess.pydataprocess.CSemanticSegmentationIO¶
Define input or output managing common information extracted by semantic segmentation task. Such task are able to automatically set a class for each pixel of an image. Thus, this input/output stores labelled image, class names and class colors. Among others, algorithms like DeepLabV3+, UNet or TransUNet are semantic segmentation tasks.
Import
from ikomia.dataprocess import CSemanticSegmentationIO
Methods
__init__(arg1)__init__( (object)self) -> None :
get_mask(self)Get labelled image (ie graylevel) where each pixel has a specific value corresponding to its class.
get_class_names(self)Get class names list associated with the semantic mask.
get_colors(self)Get colors associated with class names.
get_polygons(self)Get polygons of connected components extracted from segmentation mask.
set_class_colors(self, colors)Set class colors associated with segmentation mask.
set_class_names(self, names)Set class names associated with segmentation mask.
set_mask(self, mask)Set the mask of the semantic segmentation output.
Overridden methods
clear_data(self)See
clear_data().from_json(self, jsonStr)Set input/output data from JSON formatted string.
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).
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_saveAuto-save status
data_typeI/O data type
dim_countNumber of dimensions
descriptionCustom description to explain input/output type and use
displayableDisplayable status (Ikomia Studio)
nameI/O name
source_file_pathPath to the source file used as workflow input (if any)
Details
- __init__((object)arg1) None¶
- __init__( (object)self) -> None :
Default constructor
- __init__( (object)arg1, (CSemanticSegmentationIO)arg2) -> None :
Copy constructor
- from_json((CSemanticSegmentationIO)self, (str)jsonStr) None :¶
Set input/output data from JSON formatted string.
Args:
str: data as JSON formatted string
from_json( (CSemanticSegmentationIO)self, (str)jsonStr) -> None
- get_mask((CSemanticSegmentationIO)self) object :¶
Get labelled image (ie graylevel) where each pixel has a specific value corresponding to its class. You can find the correspondence between pixel value and class name with
ikomia.dataprocess.pydataprocess.CSemanticIO.get_class_names().- Returns:
grayscale mask
- Return type:
Numpy array
- get_class_names((CSemanticSegmentationIO)self) object :¶
Get class names list associated with the semantic mask. Class index in the list corresponds to the pixel value in the mask.
- Returns:
class names
- Return type:
list of str
- get_colors((CSemanticSegmentationIO)self) object :¶
Get colors associated with class names.
- Returns:
colors as [r, g, b] list
- Return type:
list of int list
- get_polygons((CSemanticSegmentationIO)self) object :¶
Get polygons of connected components extracted from segmentation mask.
- Returns:
list of
CGraphicsItembased objects
- is_data_available((CSemanticSegmentationIO)self) bool :¶
See
is_data_available().is_data_available( (CSemanticSegmentationIO)self) -> bool
- load((CSemanticSegmentationIO)self, (str)path) None :¶
Load instance segmentation input/output for JSON file.
Args:
path (str): path to JSON file
load( (CSemanticSegmentationIO)self, (str)path) -> None
- save((CSemanticSegmentationIO)self, (str)path) None :¶
Save instance segmentation input/output to JSON file.
Args:
path (str): path to JSON file
save( (CSemanticSegmentationIO)self, (str)path) -> None
- set_class_names((CSemanticSegmentationIO)self, (object)names) None :¶
Set class names associated with segmentation mask. If colors are not defined, random colors are automatically generated.
- Parameters:
names (list of str) – class names, index in the list must match the pixel value in the mask
- set_class_colors((CSemanticSegmentationIO)self, (object)colors) None :¶
Set class colors associated with segmentation mask. Sizes of names and colors must be equal.
- Parameters:
colors (list of list of int) – colors as [r, g, b] list
- set_mask((CSemanticSegmentationIO)self, (object)mask) None :¶
Set the mask of the semantic segmentation output.
- Parameters:
mask (numpy array) – segmentation mask
- to_json((CSemanticSegmentationIO)self) str :¶
- Return input/output data in JSON formatted string (compact mode and image encoded as JPEG).
Returns:
string: JSON formatted string
to_json( (CSemanticSegmentationIO)self) -> str
- to_json( (CSemanticSegmentationIO)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( (CSemanticSegmentationIO)self, (object)options) -> str