tensorbay.label.label_mask#

The implementation of the TensorBay mask label.

class tensorbay.label.label_mask.SemanticMaskSubcatalog(description='')[source]#

Bases: tensorbay.label.basic.SubcatalogBase, tensorbay.label.supports.MaskCategoriesMixin, tensorbay.label.supports.AttributesMixin

This class defines the subcatalog for semantic mask type of labels.

Parameters

description (str) –

Return type

None

description#

The description of the entire semantic mask subcatalog.

Type

str

categories#

All the possible categories in the corresponding dataset stored in a NameList with the category names as keys and the CategoryInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.supports.MaskCategoryInfo]

category_delimiter#

The delimiter in category values indicating parent-child relationship.

Type

str

attributes#

All the possible attributes in the corresponding dataset stored in a NameList with the attribute names as keys and the AttributeInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.attributes.AttributeInfo]

is_tracking#

Whether the Subcatalog contains tracking information.

Examples

Initialization Method 1: Init from SemanticMaskSubcatalog.loads() method.

>>> catalog = {
...     "SEMANTIC_MASK": {
...         "categories": [
...             {'name': 'cat', "categoryId": 1},
...             {'name': 'dog', "categoryId": 2}
...         ],
...         "attributes": [{'name': 'occluded', 'type': 'boolean'}],
...     }
... }
>>> SemanticMaskSubcatalog.loads(catalog["SEMANTIC_MASK"])
SemanticMaskSubcatalog(
  (categories): NameList [...],
  (attributes): NameList [...]
)

Initialization Method 2: Init an empty SemanticMaskSubcatalog and then add the attributes.

>>> semantic_mask_subcatalog = SemanticMaskSubcatalog()
>>> semantic_mask_subcatalog.add_category("cat", 1)
>>> semantic_mask_subcatalog.add_category("dog", 2)
>>> semantic_mask_subcatalog.add_attribute("occluded", type_="boolean")
>>> semantic_mask_subcatalog
SemanticMaskSubcatalog(
  (categories): NameList [...],
  (attributes): NameList [...]
)
class tensorbay.label.label_mask.InstanceMaskSubcatalog(description='')[source]#

Bases: tensorbay.label.basic.SubcatalogBase, tensorbay.label.supports.MaskCategoriesMixin, tensorbay.label.supports.IsTrackingMixin, tensorbay.label.supports.AttributesMixin

This class defines the subcatalog for instance mask type of labels.

Parameters

description (str) –

Return type

None

description#

The description of the entire instance mask subcatalog.

Type

str

categories#

All the possible categories in the corresponding dataset stored in a NameList with the category names as keys and the CategoryInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.supports.MaskCategoryInfo]

category_delimiter#

The delimiter in category values indicating parent-child relationship.

Type

str

attributes#

All the possible attributes in the corresponding dataset stored in a NameList with the attribute names as keys and the AttributeInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.attributes.AttributeInfo]

is_tracking#

Whether the Subcatalog contains tracking information.

Type

bool

Examples

Initialization Method 1: Init from InstanceMaskSubcatalog.loads() method.

>>> catalog = {
...     "INSTANCE_MASK": {
...         "categories": [
...             {'name': 'background', "categoryId": 0}
...         ],
...         "attributes": [{'name': 'occluded', 'type': 'boolean'}],
...     }
... }
>>> InstanceMaskSubcatalog.loads(catalog["INSTANCE_MASK"])
InstanceMaskSubcatalog(
  (is_tracking): False,
  (categories): NameList [...],
  (attributes): NameList [...]
)

Initialization Method 2: Init an empty InstanceMaskSubcatalog and then add the attributes.

>>> instance_mask_subcatalog = InstanceMaskSubcatalog()
>>> instance_mask_subcatalog.add_category("background", 0)
>>> instance_mask_subcatalog.add_attribute("occluded", type_="boolean")
>>> instance_mask_subcatalog
InstanceMaskSubcatalog(
  (categories): NameList [...],
  (attributes): NameList [...]
)
class tensorbay.label.label_mask.PanopticMaskSubcatalog(description='')[source]#

Bases: tensorbay.label.basic.SubcatalogBase, tensorbay.label.supports.MaskCategoriesMixin, tensorbay.label.supports.AttributesMixin

This class defines the subcatalog for panoptic mask type of labels.

Parameters

description (str) –

Return type

None

description#

The description of the entire panoptic mask subcatalog.

Type

str

categories#

All the possible categories in the corresponding dataset stored in a NameList with the category names as keys and the CategoryInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.supports.MaskCategoryInfo]

category_delimiter#

The delimiter in category values indicating parent-child relationship.

Type

str

attributes#

All the possible attributes in the corresponding dataset stored in a NameList with the attribute names as keys and the AttributeInfo as values.

Type

tensorbay.utility.name.NameList[tensorbay.label.attributes.AttributeInfo]

is_tracking#

Whether the Subcatalog contains tracking information.

Examples

Initialization Method 1: Init from PanopticMaskSubcatalog.loads() method.

>>> catalog = {
...     "PANOPTIC_MASK": {
...         "categories": [
...             {'name': 'cat', "categoryId": 1},
...             {'name': 'dog', "categoryId": 2}
...         ],
...         "attributes": [{'name': 'occluded', 'type': 'boolean'}],
...     }
... }
>>> PanopticMaskSubcatalog.loads(catalog["PANOPTIC_MASK"])
PanopticMaskSubcatalog(
  (categories): NameList [...],
  (attributes): NameList [...]
)

Initialization Method 2: Init an empty PanopticMaskSubcatalog and then add the attributes.

>>> panoptic_mask_subcatalog = PanopticMaskSubcatalog()
>>> panoptic_mask_subcatalog.add_category("cat", 1)
>>> panoptic_mask_subcatalog.add_category("dog", 2)
>>> panoptic_mask_subcatalog.add_attribute("occluded", type_="boolean")
>>> panoptic_mask_subcatalog
PanopticMaskSubcatalog(
  (categories): NameList [...],
  (attributes): NameList [...]
)
class tensorbay.label.label_mask.SemanticMaskBase[source]#

Bases: tensorbay.utility.repr.ReprMixin

SemanticMaskBase is a base class for the semantic mask label.

all_attributes#

The dict of the attributes in this mask, which key is the category id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

class tensorbay.label.label_mask.InstanceMaskBase[source]#

Bases: tensorbay.utility.repr.ReprMixin

InstanceMaskBase is a base class for the instance mask label.

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

class tensorbay.label.label_mask.PanopticMaskBase[source]#

Bases: tensorbay.utility.repr.ReprMixin

PanopticMaskBase is a base class for the panoptic mask label.

Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

all_category_ids#

The dict of the category id in this mask, which key is the instance id, and the value is the corresponding category id.

class tensorbay.label.label_mask.SemanticMask(local_path)[source]#

Bases: tensorbay.label.label_mask.SemanticMaskBase, tensorbay.utility.file.FileMixin

SemanticMask is a class for the local semantic mask label.

Parameters

local_path (str) –

Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the category id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

get_callback_body()[source]#

Get the callback request body for uploading.

Returns

The callback request body, which looks like:

{
    "checksum": <str>,
    "fileSize": <int>,
    "info": [
        {
            "categoryId": 0,
            "attributes": {
                "occluded": True
            }
        },
        {
            "categoryId": 1,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Return type

Dict[str, Any]

class tensorbay.label.label_mask.InstanceMask(local_path)[source]#

Bases: tensorbay.label.label_mask.InstanceMaskBase, tensorbay.utility.file.FileMixin

InstanceMask is a class for the local instance mask label.

Parameters

local_path (str) –

Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

get_callback_body()[source]#

Get the callback request body for uploading.

Returns

The callback request body, which looks like:

{
    "checksum": <str>,
    "fileSize": <int>,
    "info": [
        {
            "instanceId": 0,
            "attributes": {
                "occluded": True
            }
        },
        {
            "instanceId": 1,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Return type

Dict[str, Any]

class tensorbay.label.label_mask.PanopticMask(local_path)[source]#

Bases: tensorbay.label.label_mask.PanopticMaskBase, tensorbay.utility.file.FileMixin

PanopticMask is a class for the local panoptic mask label.

Parameters

local_path (str) –

Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

all_category_ids#

The dict of the category id in this mask, which key is the instance id, and the value is the corresponding category id.

get_callback_body()[source]#

Get the callback request body for uploading.

Returns

The callback request body, which looks like:

{
    "checksum": <str>,
    "fileSize": <int>,
    "info": [
        {
            "instanceId": 0,
            "categoryId": 100,
            "attributes": {
                "occluded": True
            }
        },
        {
            "instanceId": 1,
            "categoryId": 101,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Return type

Dict[str, Any]

class tensorbay.label.label_mask.RemoteSemanticMask(remote_path, *, url=None, cache_path='')[source]#

Bases: tensorbay.label.label_mask.SemanticMaskBase, tensorbay.utility.file.RemoteFileMixin

RemoteSemanticMask is a class for the remote semantic mask label.

Parameters
Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the category id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

classmethod from_response_body(body)[source]#

Loads a RemoteSemanticMask object from a response body.

Parameters

body (Dict[str, Any]) –

The response body which contains the information of a remote semantic mask, whose format should be like:

{
    "remotePath": <str>,
    "info": [
        {
            "categoryId": 0,
            "attributes": {
                "occluded": True
            }
        },
        {
            "categoryId": 1,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Returns

The loaded RemoteSemanticMask object.

Return type

tensorbay.label.label_mask._T

class tensorbay.label.label_mask.RemoteInstanceMask(remote_path, *, url=None, cache_path='')[source]#

Bases: tensorbay.label.label_mask.InstanceMaskBase, tensorbay.utility.file.RemoteFileMixin

RemoteInstanceMask is a class for the remote instance mask label.

Parameters
Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

classmethod from_response_body(body)[source]#

Loads a RemoteInstanceMask object from a response body.

Parameters

body (Dict[str, Any]) –

The response body which contains the information of a remote instance mask, whose format should be like:

{
    "remotePath": <str>,
    "info": [
        {
            "instanceId": 0,
            "attributes": {
                "occluded": True
            }
        },
        {
            "instanceId": 1,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Returns

The loaded RemoteInstanceMask object.

Return type

tensorbay.label.label_mask._T

class tensorbay.label.label_mask.RemotePanopticMask(remote_path, *, url=None)[source]#

Bases: tensorbay.label.label_mask.PanopticMaskBase, tensorbay.utility.file.RemoteFileMixin

RemotePanoticMask is a class for the remote panotic mask label.

Parameters
Return type

None

all_attributes#

The dict of the attributes in this mask, which key is the instance id, and the value is the corresponding attributes.

Type

Dict[int, Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]]

classmethod from_response_body(body)[source]#

Loads a RemotePanopticMask object from a response body.

Parameters

body (Dict[str, Any]) –

The response body which contains the information of a remote panoptic mask, whose format should be like:

{
    "remotePath": <str>,
    "info": [
        {
            "instanceId": 0,
            "categoryId": 100,
            "attributes": {
                "occluded": True
            }
        },
        {
            "instanceId": 1,
            "categoryId": 101,
            "attributes": {
                "occluded": False
            }
        }
    ]
}

Returns

The loaded RemotePanopticMask object.

Return type

tensorbay.label.label_mask._T