otx.core.types#

Module reserved for definitions used in OTX.

Classes

LabelInfo(label_names, label_groups)

Object to represent label information.

HLabelInfo(label_names, label_groups, ...)

The label information represents the hierarchy.

SegLabelInfo(label_names, label_groups[, ...])

Meta information of Semantic Segmentation.

NullLabelInfo()

Represent no label information.

OTXTaskType(value)

OTX task type definition.

class otx.core.types.HLabelInfo(label_names: list[str], label_groups: list[list[str]], num_multiclass_heads: int, num_multilabel_classes: int, head_idx_to_logits_range: dict[str, tuple[int, int]], num_single_label_classes: int, class_to_group_idx: dict[str, tuple[int, int]], all_groups: list[list[str]], label_to_idx: dict[str, int], label_tree_edges: list[list[str]], empty_multiclass_head_indices: list[int])[source]#

Bases: LabelInfo

The label information represents the hierarchy.

All params should be kept since they’re also used at the Model API side.

Parameters:
  • num_multiclass_heads – the number of the multiclass heads

  • num_multilabel_classes – the number of multilabel classes

  • head_to_logits_range – the logit range of each heads

  • num_single_label_classes – the number of single label classes

  • class_to_group_idx – represents the head index and label index

  • all_groups – represents information of all groups

  • label_to_idx – index of each label

  • empty_multiclass_head_indices – the index of head that doesn’t include any label due to the label removing

i.e. Single-selection group information (Multiclass, Exclusive) {

“Shape”: [“Rigid”, “Non-Rigid”], “Rigid”: [“Rectangle”, “Triangle”], “Non-Rigid”: [“Circle”]

}

Multi-selection group information (Multilabel) {

“Animal”: [“Lion”, “Panda”]

}

In the case above, HlabelInfo will be generated as below. NOTE, If there was only one label in the multiclass group, it will be handeled as multilabel(Circle).

num_multiclass_heads: 2 (Shape, Rigid) num_multilabel_classes: 3 (Circle, Lion, Panda) head_to_logits_range: {‘0’: (0, 2), ‘1’: (2, 4)} (Each multiclass head have 2 labels) num_single_label_classes: 4 (Rigid, Non-Rigid, Rectangle, Triangle) class_to_group_idx: {

‘Non-Rigid’: (0, 0), ‘Rigid’: (0, 1), ‘Rectangle’: (1, 0), ‘Triangle’: (1, 1), ‘Circle’: (2, 0), ‘Lion’: (2,1), ‘Panda’: (2,2)

} (head index, label index for each head) all_groups: [[‘Non-Rigid’, ‘Rigid’], [‘Rectangle’, ‘Triangle’], [‘Circle’], [‘Lion’], [‘Panda’]] label_to_idx: {

‘Rigid’: 0, ‘Rectangle’: 1, ‘Triangle’: 2, ‘Non-Rigid’: 3, ‘Circle’: 4 ‘Lion’: 5, ‘Panda’: 6

} label_tree_edges: [

[“Rectangle”, “Rigid”], [“Triangle”, “Rigid”], [“Circle”, “Non-Rigid”],

] # NOTE, label_tree_edges format could be changed. empty_multiclass_head_indices: []

All of the member variables should be considered for the Model API. openvinotoolkit/training_extensions

as_head_config_dict() dict[str, Any][source]#

Return a dictionary including params needed to configure the HLabel MMPretrained head network.

classmethod from_dm_label_groups(dm_label_categories: LabelCategories) HLabelInfo[source]#

Generate HLabelData from the Datumaro LabelCategories.

Parameters:

dm_label_categories (LabelCategories) – the label categories of datumaro.

classmethod from_json(serialized: str) HLabelInfo[source]#

Reconstruct it from the JSON serialized string.

class otx.core.types.LabelInfo(label_names: list[str], label_groups: list[list[str]])[source]#

Bases: object

Object to represent label information.

as_dict() dict[str, Any][source]#

Return a dictionary including all params.

classmethod from_dm_label_groups(dm_label_categories: LabelCategories) LabelInfo[source]#

Create this object from the datumaro label groups.

Parameters:

dm_label_categories (LabelCategories) – The label category information from Datumaro.

Returns:

LabelInfo(

label_names=[“Heart_King”, “Heart_Queen”, “Spade_King”, “Spade_Jack”] label_groups=[[“Heart_King”, “Heart_Queen”], [“Spade_King”, “Spade_Jack”]]

)

classmethod from_json(serialized: str) LabelInfo[source]#

Reconstruct it from the JSON serialized string.

classmethod from_num_classes(num_classes: int) LabelInfo[source]#

Create this object from the number of classes.

Parameters:

num_classes – Number of classes

Returns:

LabelInfo(

label_names=[“label_0”, …], label_groups=[[“label_0”, …]]

)

to_json() str[source]#

Return JSON serialized string.

property num_classes: int#

Return number of labels.

class otx.core.types.NullLabelInfo[source]#

Bases: LabelInfo

Represent no label information. It is used for Visual Prompting tasks.

classmethod from_json(_: str) LabelInfo[source]#

Reconstruct it from the JSON serialized string.

class otx.core.types.OTXTaskType(value)[source]#

Bases: str, Enum

OTX task type definition.

class otx.core.types.SegLabelInfo(label_names: list[str], label_groups: list[list[str]], ignore_index: int = 255)[source]#

Bases: LabelInfo

Meta information of Semantic Segmentation.

classmethod from_num_classes(num_classes: int) LabelInfo[source]#

Create this object from the number of classes.

Parameters:

num_classes – Number of classes

Returns:

LabelInfo(

label_names=[“Background”, “label_0”, …, “label_{num_classes - 1}”] label_groups=[[“Background”, “label_0”, …, “label_{num_classes - 1}”]]

)