kwimage.structs._generic
¶
Module Contents¶
Classes¶
Abstract base class defining the spatial annotation API |
|
Stores a list of potentially heterogenous structures, each item usually |
Functions¶
|
helper for ensuring out.dtype == in.dtype |
|
|
|
|
|
Uses string comparisons to avoid ipython reload errors. |
|
Uses string comparisons to avoid ipython reload errors. |
Attributes¶
- class kwimage.structs._generic.Spatial[source]¶
Bases:
ubelt.NiceRepr
Abstract base class defining the spatial annotation API
- class kwimage.structs._generic.ObjectList(data, meta=None)[source]¶
Bases:
Spatial
Stores a list of potentially heterogenous structures, each item usually corresponds to a different object.
- classmethod concatenate(cls, items, axis=0)[source]¶
- Parameters
items (Sequence[ObjectList]) – multiple object lists of the same type
axis (int | None) – unused, always implied to be axis 0
- Returns
combined object list
- Return type
Example
>>> import kwimage >>> cls = kwimage.MaskList >>> sub_cls = kwimage.Mask >>> item1 = cls([sub_cls.random(), sub_cls.random()]) >>> item2 = cls([sub_cls.random()]) >>> items = [item1, item2] >>> new = cls.concatenate(items) >>> assert len(new) == 3
- kwimage.structs._generic._consistent_dtype_fixer(data)[source]¶
helper for ensuring out.dtype == in.dtype
- kwimage.structs._generic._issubclass2(child, parent)[source]¶
Uses string comparisons to avoid ipython reload errors. Much less robust though.
- kwimage.structs._generic._isinstance2(obj, cls)[source]¶
Uses string comparisons to avoid ipython reload errors. Much less robust though.
Example
import kwimage from kwimage.structs import _generic cls = kwimage.structs._generic.ObjectList obj = kwimage.MaskList([]) _generic._isinstance2(obj, cls)
_generic._isinstance2(kwimage.MaskList([]), _generic.ObjectList)
- dets = kwimage.Detections(
boxes=kwimage.Boxes.random(3).numpy(), class_idxs=[0, 1, 1], segmentations=kwimage.MaskList([None] * 3)
)