tensorbay.label.catalog
Catalog.
Catalog is used to describe the types of labels
contained in a DatasetBase and
all the optional values of the label contents.
A Catalog contains one or several SubcatalogBase,
corresponding to different types of labels.
subcatalog classes |
explaination |
|---|---|
subcatalog for classification type of label |
|
subcatalog for 2D bounding box type of label |
|
subcatalog for 3D bounding box type of label |
|
subcatalog for 2D keypoints type of label |
|
subcatalog for polygon type of label |
|
subcatalog for 2D polyline type of label |
|
subcatalog for multiple polygon type of label |
|
subcatalog for rle mask type of label |
|
subcatalog for 2D multiple polyline type of label |
|
subcatalog for transcripted sentence type of label |
- 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'}]}}