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.

Table 8 subcatalog classes

subcatalog classes

explaination

ClassificationSubcatalog

subcatalog for classification type of label

Box2DSubcatalog

subcatalog for 2D bounding box type of label

Box3DSubcatalog

subcatalog for 3D bounding box type of label

Keypoints2DSubcatalog

subcatalog for 2D keypoints type of label

PolygonSubcatalog

subcatalog for polygon type of label

Polyline2DSubcatalog

subcatalog for 2D polyline type of label

MultiPolygonSubcatalog

subcatalog for multiple polygon type of label

RLESubcatalog

subcatalog for rle mask type of label

MultiPolyline2DSubcatalog

subcatalog for 2D multiple polyline type of label

SentenceSubcatalog

subcatalog for transcripted sentence type of label

class tensorbay.label.catalog.Catalog[source]

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

This class defines the concept of 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. Each of the SubcatalogBase contains 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: Dict[str, Any]) tensorbay.label.catalog._T[source]

Load a Catalog from a dict containing the catalog information.

Parameters

contents – A dict containing all the information of the catalog.

Returns

The loaded Catalog object.

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() Dict[str, Any][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.

Examples

>>> # catalog is the instance initialized above.
>>> catalog.dumps()
{'CLASSIFICATION': {'categories': [{'name': 'example'}]}}