tensorbay.label.label#
The implementation of the TensorBay 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)[source]#
Loads data from a dict containing the labels information.
- Parameters
contents (Dict[str, Any]) – A dict containing the labels information.
- Returns
A
Label
instance containing labels information from the given dict.- Return type
tensorbay.label.label._T
Examples
>>> contents = { ... "CLASSIFICATION": { ... "category": "example_category", ... "attributes": {"example_attribute1": "a"} ... } ... } >>> Label.loads(contents) Label( (classification): Classification( (category): 'example_category', (attributes): {...} ) )
- dumps()[source]#
Dumps all labels into a dict.
- Returns
Dumped labels dict.
- Return type
Dict[str, Any]
Examples
>>> from tensorbay.label import Classification >>> label = Label() >>> label.classification = Classification("category1", {"attribute1": "a"}) >>> label.dumps() {'CLASSIFICATION': {'category': 'category1', 'attributes': {'attribute1': 'a'}}}