IkDatasetIO#

class ikomia.dnn.datasetio.IkDatasetIO(format='other')#

Define task input or output containing deep learning dataset structure. Derived from CDatasetIO.

Instances can be added as input or output of a CWorkflowTask or derived object. Such input or output is required for deep learning training task. Dataset structure is composed of a global dict with 2 main entries ‘images’ and ‘metadata’.

It follows the specifications below (mandatory fields may vary depending on the training goal).

  • images (list[dict]): image information and corresponding annotations.

    • filename (str): full path of the image file.

    • height, width (int): size of the image.

    • image_id (int): unique image identifier.

    • annotations (list[dict]): each dict corresponds to annotations of one instance in this image.

      • bbox (list[float]): x, y, width, height of the bounding box.

      • category_id (int): integer representing the category label.

      • segmentation_poly (list[list[float]]): list of polygons, one for each connected component.

      • keypoints (list[float]).

      • iscrowd (boolean): whether the instance is labelled as a crowd region (COCO).

    • segmentation_masks_np (numpy array [N, H, W]).

    • instance_seg_masks_file: full path of the ground truth instance segmentation image file.

    • semantic_seg_masks_file: full path of the ground truth semantic segmentation image file.

  • metadata (dict): key-value mapping that contains information that’s shared among the entire dataset.

    • category_names (dict(id, name)).

    • category_colors (list[tuple(r,g,b)]).

    • keypoint_names (list[str]).

    • keypoint_connection_rules (list[tuple(str, str, (r,g,b))]): each tuple specifies a pair of connected keypoints and the color to use for the line between them.

Import

from ikomia.dnn.datasetio import IkDatasetIO

Methods

__init__([format])

Constructor

clear_data()

Clear whole dataset structure

get_categories()

Return the list of categories (ie instance classes) in the dataset.

get_category_count()

Return the number of categories (ie instance classes) in the dataset.

get_graphics_annotations(img_path)

Return a list of Ikomia graphics items corresponding to the annotations of a given image (bounding box, polygons).

get_image_paths()

Return the list of all images path contained in the dataset.

get_mask_path(img_path)

Return the file path of the segmentation mask for the given image.

get_source_format(arg1)

Get the source format of the dataset.

is_data_available()

Check whether the dataset structure contains data.

load(path)

Load JSON as dataset structure.

save(path)

Save dataset structure as JSON.

Details

__init__(format='other')#

Constructor

Parameters:

format (str) – dataset source format.

clear_data()#

Clear whole dataset structure

get_categories()#

Return the list of categories (ie instance classes) in the dataset.

Returns:

categories (dict-like structure)

Return type:

MapIntStr list

get_category_count()#

Return the number of categories (ie instance classes) in the dataset.

Returns:

int

get_graphics_annotations(img_path)#

Return a list of Ikomia graphics items corresponding to the annotations of a given image (bounding box, polygons).

Parameters:

img_path (str) – path of the image from which we want annotations

Returns:

graphics items

Return type:

CGraphicsItem list

get_image_paths()#

Return the list of all images path contained in the dataset.

Returns:

path list

Return type:

str[]

get_mask_path(img_path)#

Return the file path of the segmentation mask for the given image.

Parameters:

img_path (str) – path of the image from which segmentation mask is requested

Returns:

file path of the segmentation mask

Return type:

str

get_source_format((CDatasetIO)arg1) str :#

Get the source format of the dataset.

Returns:

source format string identifier (lowercase)

Return type:

str

is_data_available()#

Check whether the dataset structure contains data.

Returns:

True or False

Return type:

boolean

load(path)#

Load JSON as dataset structure.

Parameters:

path – file path where dataset is saved

save(path)#

Save dataset structure as JSON.

Parameters:

path – file path where dataset is saved