datumaro.components.annotation#
Module Attributes
Represents { index -> color } mapping for segmentation masks |
Classes
|
A base annotation class. |
|
An enumeration. |
|
Method generated by attrs for class _Shape. |
|
Represents arbitrary text annotations. |
|
A base class for annotation metainfo. |
|
Represents class- and instance- segmentation masks with all the instances (opposed to single-instance masks). |
|
Method generated by attrs for class Annotation. |
|
Represents depth images. |
|
Ellipse represents an ellipse that is encapsulated by a rectangle. |
|
Method generated by attrs for class FeatureVector. |
|
An enumeration. |
|
Method generated by attrs for class HashKey. |
|
Method generated by attrs for class Label. |
|
Method generated by attrs for class LabelCategories. |
|
Represents a 2d single-instance binary segmentation mask. |
|
Describes a color map for segmentation masks. |
|
Represents an ordered set of points. |
|
Describes (key-)point metainfo such as point names and joints. |
|
Method generated by attrs for class PolyLine. |
|
Method generated by attrs for class Polygon. |
|
An RLE-encoded instance segmentation mask. |
|
Represents high resolution images. |
|
Represents values of target columns in a tabular dataset. |
|
Describes tabular data metainfo such as column names and types. |
- class datumaro.components.annotation.AnnotationType(value)[source]#
Bases:
IntEnum
An enumeration.
- unknown = 0#
- label = 1#
- mask = 2#
- points = 3#
- polygon = 4#
- polyline = 5#
- bbox = 6#
- caption = 7#
- cuboid_3d = 8#
- super_resolution_annotation = 9#
- depth_annotation = 10#
- ellipse = 11#
- hash_key = 12#
- feature_vector = 13#
- tabular = 14#
- class datumaro.components.annotation.Annotation(*, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
object
A base annotation class.
Derived classes must define the ‘_type’ class variable with a value from the AnnotationType enum.
Method generated by attrs for class Annotation.
- property type: AnnotationType#
- class datumaro.components.annotation.Categories(*, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
object
A base class for annotation metainfo. It is supposed to include dataset-wide metainfo like available labels, label colors, label attributes etc.
Method generated by attrs for class Categories.
- class datumaro.components.annotation.GroupType(value)[source]#
Bases:
IntEnum
An enumeration.
- EXCLUSIVE = 0#
- INCLUSIVE = 1#
- RESTRICTED = 2#
- class datumaro.components.annotation.LabelCategories(items: List[str] = _Nothing.NOTHING, label_groups: List[LabelGroup] = _Nothing.NOTHING, *, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
Categories
Method generated by attrs for class LabelCategories.
- class Category(name, parent: str = '', attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
object
Method generated by attrs for class LabelCategories.Category.
- class LabelGroup(name, labels: List[str] = [], group_type: GroupType = GroupType.EXCLUSIVE)[source]#
Bases:
object
Method generated by attrs for class LabelCategories.LabelGroup.
- label_groups: List[LabelGroup]#
- classmethod from_iterable(iterable: Iterable[Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, List[str]]]]) LabelCategories [source]#
Creates a LabelCategories from iterable.
- Parameters:
iterable –
This iterable object can be:
a list of str - will be interpreted as list of Category names
a list of positional arguments - will generate Categories with these arguments
Returns: a LabelCategories object
- class datumaro.components.annotation.Label(label, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Method generated by attrs for class Label.
- class datumaro.components.annotation.HashKey(hash_key: ndarray, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Method generated by attrs for class HashKey.
- class datumaro.components.annotation.FeatureVector(vector: ndarray, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Method generated by attrs for class FeatureVector.
- datumaro.components.annotation.Colormap#
Represents { index -> color } mapping for segmentation masks
- class datumaro.components.annotation.MaskCategories(colormap: Dict[int, Tuple[int, int, int]] = _Nothing.NOTHING, inverse_colormap: Optional[Dict[Tuple[int, int, int], int]] = None, *, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
Categories
Describes a color map for segmentation masks.
Method generated by attrs for class MaskCategories.
- classmethod generate(size: int = 255, include_background: bool = True) MaskCategories [source]#
Generates MaskCategories with the specified size.
- If include_background is True, the result will include the item
“0: (0, 0, 0)”, which is typically used as a background color.
- class datumaro.components.annotation.Mask(image, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Annotation
Represents a 2d single-instance binary segmentation mask.
Method generated by attrs for class Mask.
- as_class_mask(label_id: Optional[int] = None) ndarray [source]#
Produces a class index mask. Mask label id can be changed.
- class datumaro.components.annotation.RleMask(rle, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Mask
An RLE-encoded instance segmentation mask.
Method generated by attrs for class RleMask.
- property rle#
- class datumaro.components.annotation.CompiledMask(class_mask: Union[None, ndarray, Callable[[], ndarray]] = None, instance_mask: Union[None, ndarray, Callable[[], ndarray]] = None)[source]#
Bases:
object
Represents class- and instance- segmentation masks with all the instances (opposed to single-instance masks).
- static from_instance_masks(instance_masks: Iterable[Mask], instance_ids: Optional[Iterable[int]] = None, instance_labels: Optional[Iterable[int]] = None) CompiledMask [source]#
Joins instance masks into a single mask. Masks are sorted by z_order (ascending) prior to merging.
- Parameters:
instance_ids – Instance id values for the produced instance mask. By default, mask positions are used.
instance_labels – Instance label id values for the produced class mask. By default, mask labels are used.
- class datumaro.components.annotation.PolyLine(points, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
_Shape
Method generated by attrs for class PolyLine.
- class datumaro.components.annotation.Cuboid3d(position, rotation=None, scale=None, **kwargs)[source]#
Bases:
Annotation
Method generated by attrs for class Annotation.
- property position#
[x, y, z]
- property rotation#
[rx, ry, rz]
- property scale#
[sx, sy, sz]
- class datumaro.components.annotation.Polygon(points, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
_Shape
Method generated by attrs for class Polygon.
- class datumaro.components.annotation.Bbox(x, y, w, h, *args, **kwargs)[source]#
Bases:
_Shape
Method generated by attrs for class _Shape.
- property x#
- property y#
- property w#
- property h#
- class datumaro.components.annotation.PointsCategories(items: Dict[int, Category] = _Nothing.NOTHING, *, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
Categories
Describes (key-)point metainfo such as point names and joints.
Method generated by attrs for class PointsCategories.
- class Category(labels: List[str] = _Nothing.NOTHING, joints: Set[Tuple[int, int]] = _Nothing.NOTHING)[source]#
Bases:
object
Method generated by attrs for class PointsCategories.Category.
- classmethod from_iterable(iterable: Union[Tuple[int, List[str]], Tuple[int, List[str], Set[Tuple[int, int]]]]) PointsCategories [source]#
Create PointsCategories from an iterable.
- Parameters:
iterable –
An Iterable with the following elements:
a label id
a list of positional arguments for Categories
- Returns:
PointsCategories object
- Return type:
- class datumaro.components.annotation.Points(points, visibility: Optional[List[IntEnum]] = None, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
_Shape
Represents an ordered set of points.
Method generated by attrs for class Points.
- class datumaro.components.annotation.Caption(caption, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Represents arbitrary text annotations.
Method generated by attrs for class Caption.
- class datumaro.components.annotation.SuperResolutionAnnotation(image: Image, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
_ImageAnnotation
Represents high resolution images.
Method generated by attrs for class SuperResolutionAnnotation.
- class datumaro.components.annotation.DepthAnnotation(image: Image, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
_ImageAnnotation
Represents depth images.
Method generated by attrs for class DepthAnnotation.
- class datumaro.components.annotation.Ellipse(x1: float, y1: float, x2: float, y2: float, *args, **kwargs)[source]#
Bases:
_Shape
Ellipse represents an ellipse that is encapsulated by a rectangle.
x1 and y1 represent the top-left coordinate of the encapsulating rectangle
x2 and y2 representing the bottom-right coordinate of the encapsulating rectangle
- Parameters:
Method generated by attrs for class _Shape.
- property x1#
- property y1#
- property x2#
- property y2#
- property w#
- property h#
- property c_x#
- property c_y#
- get_points(num_points: int = 720) List[Tuple[float, float]] [source]#
Return points as a list of tuples, e.g. [(x0, y0), (x1, y1), …].
- Parameters:
num_points (int) – The number of boundary points of the ellipse. By default, one point is created for every 1 degree of interior angle (num_points=360).
- class datumaro.components.annotation.TabularCategories(items: List[Category] = _Nothing.NOTHING, *, attributes: Set[str] = _Nothing.NOTHING)[source]#
Bases:
Categories
Describes tabular data metainfo such as column names and types.
Method generated by attrs for class TabularCategories.
- class Category(name, dtype: Type[TableDtype], labels: Set[Union[str, int]] = _Nothing.NOTHING)[source]#
Bases:
object
Method generated by attrs for class TabularCategories.Category.
- classmethod from_iterable(iterable: Iterable[Union[Tuple[str, Type[TableDtype]], Tuple[str, Type[TableDtype], Set[str]]]]) TabularCategories [source]#
Creates a TabularCategories from iterable.
- Parameters:
iterable – a list of (Category name, type) or (Category name, type, set of labels)
Returns: a TabularCategories object