tensorbay.label.supports¶
CatagoryInfo, KeypointsInfo and different SubcatalogMixin classes.
CatagoryInfo
defines a category with the name and description of it.
KeypointsInfo
defines the structure of a set of keypoints.
mixin classes for subcatalog |
explaination |
---|---|
a mixin class supporting tracking information of a subcatalog |
|
a mixin class supporting category information of a subcatalog |
|
a mixin class supporting attribute information of a subcatalog |
- class tensorbay.label.supports.CategoryInfo(name: str, description: str = '')[source]¶
Bases:
tensorbay.utility.name.NameMixin
This class represents the information of a category, including category name and description.
- Parameters
name – The name of the category.
description – The description of the category.
- 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: Dict[str, str]) tensorbay.label.supports._T [source]¶
Loads a CategoryInfo from a dict containing the category.
- Parameters
contents – A dict containing the information of the category.
- Returns
The loaded
CategoryInfo
object.
Examples
>>> contents = {"name": "example", "description": "This is an exmaple"} >>> CategoryInfo.loads(contents) CategoryInfo("example")
- dumps() Dict[str, str] [source]¶
Dumps the CatagoryInfo into a dict.
- Returns
A dict containing the information in the CategoryInfo.
Examples
>>> categoryinfo = CategoryInfo(name="example", description="This is an example") >>> categoryinfo.dumps() {'name': 'example', 'description': 'This is an example'}
- class tensorbay.label.supports.KeypointsInfo(number: int, *, names: Optional[Iterable[str]] = None, skeleton: Optional[Iterable[Iterable[int]]] = None, visible: Optional[str] = None, parent_categories: Union[None, str, Iterable[str]] = None, description: str = '')[source]¶
Bases:
tensorbay.utility.repr.ReprMixin
,tensorbay.utility.attr.AttrsMixin
This class defines the structure of a set of keypoints.
- Parameters
number – The number of the set of keypoints.
names – All the names of the keypoints.
skeleton – The skeleton of the keypoints indicating which keypoint should connect with another.
visible – The visible type of the keypoints, can only be ‘BINARY’ or ‘TERNARY’. It determines the range of the
Keypoint2D.v
.parent_categories – The parent categories of the keypoints.
description – 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: Dict[str, Any]) tensorbay.label.supports._T [source]¶
Loads a KeypointsInfo from a dict containing the information of the keypoints.
- Parameters
contents – A dict containing all the information of the set of keypoints.
- Returns
The loaded
KeypointsInfo
object.
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() Dict[str, Any] [source]¶
Dumps all the keypoint information into a dict.
- Returns
A dict containing all the information of the keypoint.
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: bool = False)[source]¶
Bases:
tensorbay.utility.attr.AttrsMixin
A mixin class supporting tracking information of a subcatalog.
- Parameters
is_tracking – Whether the Subcatalog contains tracking information.
- 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() Dict[str, int] [source]¶
Return the dict containing the conversion from category to index.
- Returns
A dict containing the conversion from category to index.
- 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: str, *, type_: Union[str, None, Type[Optional[Union[list, bool, int, float, str]]], Iterable[Union[str, None, Type[Optional[Union[list, bool, int, float, str]]]]]] = '', enum: Optional[Iterable[Optional[Union[str, float, bool]]]] = None, minimum: Optional[float] = None, maximum: Optional[float] = None, items: Optional[tensorbay.label.attributes.Items] = None, parent_categories: Union[None, str, Iterable[str]] = None, description: str = '') None [source]¶
Add an attribute to the Subcatalog.
- Parameters
name – 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 – All the possible values of an enumeration attribute.
minimum – The minimum value of number type attribute.
maximum – The maximum value of number type attribute.
items – The items inside array type attributes.
parent_categories – The parent categories of the attribute.
description – The description of the attributes.