tensorbay.label.catalog#
The implementation of the TensorBay catalog.
- class tensorbay.label.catalog.Catalog[source]#
Bases:
tensorbay.utility.repr.ReprMixin,tensorbay.utility.attr.AttrsMixinThis class defines the concept of catalog.
Catalogis used to describe the types of labels contained in aDatasetBaseand all the optional values of the label contents.A
Catalogcontains one or severalSubcatalogBase, corresponding to different types of labels. Each of theSubcatalogBasecontains the features, fields and the specific definitions of the labels.Examples
>>> from tensorbay.utility import NameList >>> from tensorbay.label import ClassificationSubcatalog, CategoryInfo >>> classification_subcatalog = ClassificationSubcatalog() >>> categories = NameList() >>> categories.append(CategoryInfo("example")) >>> classification_subcatalog.categories = categories >>> catalog = Catalog() >>> catalog.classification = classification_subcatalog >>> catalog Catalog( (classification): ClassificationSubcatalog( (categories): NameList [...] ) )
- classmethod loads(contents)[source]#
Load a Catalog from a dict containing the catalog information.
- Parameters
contents (Dict[str, Any]) – A dict containing all the information of the catalog.
- Returns
The loaded
Catalogobject.- Return type
tensorbay.label.catalog._T
Examples
>>> contents = { ... "CLASSIFICATION": { ... "categories": [ ... { ... "name": "example", ... } ... ] ... }, ... "KEYPOINTS2D": { ... "keypoints": [ ... { ... "number": 5, ... } ... ] ... }, ... } >>> Catalog.loads(contents) Catalog( (classification): ClassificationSubcatalog( (categories): NameList [...] ), (keypoints2d): Keypoints2DSubcatalog( (is_tracking): False, (keypoints): [...] ) )
- dumps()[source]#
Dumps the catalog into a dict containing the information of all the subcatalog.
- Returns
A dict containing all the subcatalog information with their label types as keys.
- Return type
Dict[str, Any]
Examples
>>> # catalog is the instance initialized above. >>> catalog.dumps() {'CLASSIFICATION': {'categories': [{'name': 'example'}]}}