tensorbay.label.label

Label.

A Data instance contains one or several types of labels, all of which are stored in label.

Different label types correspond to different label classes classes.

Table 9 label classes

label classes

explaination

Classification

classification type of label

LabeledBox2D

2D bounding box type of label

LabeledBox3D

3D bounding box type of label

LabeledPolygon

polygon type of label

LabeledMultiPolygon

polygon lists type of label

LabeledRLE

rle mask type of label

LabeledPolyline2D

2D polyline type of label

LabeledMultiPolyline2D

2D polyline lists type of label

LabeledKeypoints2D

2D keypoints type of label

LabeledSentence

transcripted sentence type of label

class tensorbay.label.label.Label[source]

Bases: tensorbay.utility.repr.ReprMixin, tensorbay.utility.attr.AttrsMixin

This class defines label.

It contains growing types of labels referring to different tasks.

Examples

>>> from tensorbay.label import Classification
>>> label = Label()
>>> label.classification = Classification("example_category", {"example_attribute1": "a"})
>>> label
Label(
  (classification): Classification(
    (category): 'example_category',
    (attributes): {...}
  )
)
classmethod loads(contents: Dict[str, Any]) tensorbay.label.label._T[source]

Loads data from a dict containing the labels information.

Parameters

contents – A dict containing the labels information.

Returns

A Label instance containing labels information from the given dict.

Examples

>>> contents = {
...     "CLASSIFICATION": {
...         "category": "example_category",
...         "attributes": {"example_attribute1": "a"}
...     }
... }
>>> Label.loads(contents)
Label(
  (classification): Classification(
    (category): 'example_category',
    (attributes): {...}
  )
)
dumps() Dict[str, Any][source]

Dumps all labels into a dict.

Returns

Dumped labels dict.

Examples

>>> from tensorbay.label import Classification
>>> label = Label()
>>> label.classification = Classification("category1", {"attribute1": "a"})
>>> label.dumps()
{'CLASSIFICATION': {'category': 'category1', 'attributes': {'attribute1': 'a'}}}