tensorbay.label.supports#
Related supports for the TensorBay subcatalog.
- class tensorbay.label.supports.CategoryInfo(name, description='')[source]#
Bases:
tensorbay.utility.name.NameMixin
This class represents the information of a category, including category name and description.
- Parameters
name (str) – The name of the category.
description (str) – The description of the category.
- Return type
None
- name#
The name of the category.
- description#
The description of the category.
- Type
str
Examples
>>> CategoryInfo(name="example", description="This is an example") CategoryInfo("example")
- classmethod loads(contents)[source]#
Loads a CategoryInfo from a dict containing the category.
- Parameters
contents (Dict[str, str]) – A dict containing the information of the category.
- Returns
The loaded
CategoryInfo
object.- Return type
tensorbay.label.supports._T
Examples
>>> contents = {"name": "example", "description": "This is an exmaple"} >>> CategoryInfo.loads(contents) CategoryInfo("example")
- dumps()[source]#
Dumps the CatagoryInfo into a dict.
- Returns
A dict containing the information in the CategoryInfo.
- Return type
Dict[str, str]
Examples
>>> categoryinfo = CategoryInfo(name="example", description="This is an example") >>> categoryinfo.dumps() {'name': 'example', 'description': 'This is an example'}
- class tensorbay.label.supports.MaskCategoryInfo(name, category_id, description='')[source]#
Bases:
tensorbay.label.supports.CategoryInfo
This class represents the information of a category, including name, id and description.
- Parameters
name (str) – The name of the category.
category_id (int) – The id of the category.
description (str) – The description of the category.
- Return type
None
- name#
The name of the category.
- category_id#
The id of the category.
- Type
int
- description#
The description of the category.
- Type
str
Examples
>>> MaskCategoryInfo(name="example", category_id=1, description="This is an example") MaskCategoryInfo("example")( (category_id): 1 )
- class tensorbay.label.supports.KeypointsInfo(number, *, names=None, skeleton=None, visible=None, parent_categories=None, description='')[source]#
Bases:
tensorbay.utility.repr.ReprMixin
,tensorbay.utility.attr.AttrsMixin
This class defines the structure of a set of keypoints.
- Parameters
number (int) – The number of the set of keypoints.
names (List[str]) – All the names of the keypoints.
skeleton (List[Tuple[int, int]]) – The skeleton of the keypoints indicating which keypoint should connect with another.
visible (str) – The visible type of the keypoints, can only be ‘BINARY’ or ‘TERNARY’. It determines the range of the
Keypoint2D.v
.parent_categories (List[str]) – The parent categories of the keypoints.
description (str) – The description of the keypoints.
- number#
The number of the set of keypoints.
- names#
All the names of the keypoints.
- Type
List[str]
- skeleton#
The skeleton of the keypoints indicating which keypoint should connect with another.
- Type
List[Tuple[int, int]]
- visible#
The visible type of the keypoints, can only be ‘BINARY’ or ‘TERNARY’. It determines the range of the
Keypoint2D.v
.- Type
str
- parent_categories#
The parent categories of the keypoints.
- Type
List[str]
- description#
The description of the keypoints.
- Type
str
Examples
>>> KeypointsInfo( ... 2, ... names=["L_Shoulder", "R_Shoulder"], ... skeleton=[(0, 1)], ... visible="BINARY", ... parent_categories="people", ... description="example", ... ) KeypointsInfo( (number): 2, (names): [...], (skeleton): [...], (visible): 'BINARY', (parent_categories): [...] )
- classmethod loads(contents)[source]#
Loads a KeypointsInfo from a dict containing the information of the keypoints.
- Parameters
contents (Dict[str, Any]) – A dict containing all the information of the set of keypoints.
- Returns
The loaded
KeypointsInfo
object.- Return type
tensorbay.label.supports._T
Examples
>>> contents = { ... "number": 2, ... "names": ["L", "R"], ... "skeleton": [(0,1)], ... "visible": "TERNARY", ... "parentCategories": ["example"], ... "description": "example", ... } >>> KeypointsInfo.loads(contents) KeypointsInfo( (number): 2, (names): [...], (skeleton): [...], (visible): 'TERNARY', (parent_categories): [...] )
- dumps()[source]#
Dumps all the keypoint information into a dict.
- Returns
A dict containing all the information of the keypoint.
- Return type
Dict[str, Any]
Examples
>>> keypointsinfo = KeypointsInfo( ... 2, ... names=["L_Shoulder", "R_Shoulder"], ... skeleton=[(0, 1)], ... visible="BINARY", ... parent_categories="people", ... description="example", ... ) >>> keypointsinfo.dumps() { 'number': 2, 'names': ['L_Shoulder', 'R_Shoulder'], 'skeleton': [(0, 1)], 'visible': 'BINARY', 'parentCategories': ['people'], 'description': 'example', }
- class tensorbay.label.supports.IsTrackingMixin(is_tracking=False)[source]#
Bases:
tensorbay.utility.attr.AttrsMixin
A mixin class supporting tracking information of a subcatalog.
- Parameters
is_tracking (bool) – Whether the Subcatalog contains tracking information.
- Return type
None
- is_tracking#
Whether the Subcatalog contains tracking information.
- Type
bool
- class tensorbay.label.supports.CategoriesMixin[source]#
Bases:
tensorbay.utility.attr.AttrsMixin
A mixin class supporting category information of a subcatalog.
- categories#
All the possible categories in the corresponding dataset stored in a
NameList
with the category names as keys and theCategoryInfo
as values.
- category_delimiter#
The delimiter in category values indicating parent-child relationship.
- Type
str
- get_category_to_index()[source]#
Return the dict containing the conversion from category to index.
- Returns
A dict containing the conversion from category to index.
- Return type
Dict[str, int]
- class tensorbay.label.supports.MaskCategoriesMixin[source]#
Bases:
tensorbay.utility.attr.AttrsMixin
A mixin class supporting category information of a MaskSubcatalog.
- categories#
All the possible categories in the corresponding dataset stored in a
NameList
with the category names as keys and theMaskCategoryInfo
as values.
- category_delimiter#
The delimiter in category values indicating parent-child relationship.
- Type
str
- get_category_to_index()[source]#
Return the dict containing the conversion from category name to category id.
- Returns
A dict containing the conversion from category name to category id.
- Return type
Dict[str, int]
- class tensorbay.label.supports.AttributesMixin[source]#
Bases:
tensorbay.utility.attr.AttrsMixin
A mixin class supporting attribute information of a subcatalog.
- attributes#
All the possible attributes in the corresponding dataset stored in a
NameList
with the attribute names as keys and theAttributeInfo
as values.
- add_attribute(name, *, type_='', enum=None, minimum=None, maximum=None, items=None, parent_categories=None, description='')[source]#
Add an attribute to the Subcatalog.
- Parameters
name (str) – The name of the attribute.
type – The type of the attribute value, could be a single type or multi-types. The type must be within the followings: - array - boolean - integer - number - string - null - instance
enum (Optional[Iterable[Optional[Union[str, float, bool]]]]) – All the possible values of an enumeration attribute.
minimum (Optional[float]) – The minimum value of number type attribute.
maximum (Optional[float]) – The maximum value of number type attribute.
items (Optional[tensorbay.label.attributes.Items]) – The items inside array type attributes.
parent_categories (Union[None, str, Iterable[str]]) – The parent categories of the attribute.
description (str) – The description of the attributes.
type_ (Union[str, None, Type[Optional[Union[list, bool, int, float, str]]], Iterable[Union[str, None, Type[Optional[Union[list, bool, int, float, str]]]]]]) –
- Return type
None