datumaro.plugins.data_formats.arrow.mapper#

class datumaro.plugins.data_formats.arrow.mapper.DatasetItemMapper[source]#

Bases: Mapper

static forward(obj: DatasetItem, **options) Dict[str, Any][source]#

Convert an object to bytes.

static backward(idx: int, table: Table, table_path: str) DatasetItem[source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.MediaMapper[source]#

Bases: Mapper

classmethod forward(obj: MediaElement | None, **options) Dict[str, Any][source]#

Convert an object to bytes.

classmethod backward(media_struct: StructScalar, idx: int, table: Table, table_path: str) MediaElement | None[source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.AnnotationListMapper[source]#

Bases: Mapper

backward_map = {AnnotationType.label: <bound method LabelMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.LabelMapper'>>, AnnotationType.mask: <bound method MaskMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.MaskMapper'>>, AnnotationType.points: <bound method PointsMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PointsMapper'>>, AnnotationType.polygon: <bound method PolygonMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PolygonMapper'>>, AnnotationType.polyline: <bound method PolyLineMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PolyLineMapper'>>, AnnotationType.bbox: <bound method BboxMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.BboxMapper'>>, AnnotationType.caption: <bound method CaptionMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.CaptionMapper'>>, AnnotationType.cuboid_3d: <bound method Cuboid3dMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.Cuboid3dMapper'>>, AnnotationType.ellipse: <bound method EllipseMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.EllipseMapper'>>, AnnotationType.cuboid_2d: <bound method Cuboid2DMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.Cuboid2DMapper'>>}#
classmethod forward(anns: List[Annotation]) bytes[source]#

Convert an object to bytes.

classmethod backward(_bytes: bytes, offset: int = 0) Tuple[List[Annotation], int][source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.DatasetItem(id: str, *, subset: str | None = None, media: str | MediaElement | None = None, annotations: List[Annotation] | None = None, attributes: Dict[str, Any] | None = None)[source]#

Bases: object

id: str#
subset: str#
media: MediaElement | None#
annotations: Annotations#
attributes: Dict[str, Any]#
wrap(**kwargs)[source]#
media_as(t: Type[T]) T[source]#
exception datumaro.plugins.data_formats.arrow.mapper.DatumaroError[source]#

Bases: Exception

class datumaro.plugins.data_formats.arrow.mapper.DictMapper[source]#

Bases: Mapper

static forward(obj: Dict[str, Any]) bytes[source]#

Convert an object to bytes.

static backward(_bytes: bytes, offset: int = 0) Tuple[Dict[str, Any], int][source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.Image(size: Tuple[int, int] | None = None, ext: str | None = None, *args, **kwargs)[source]#

Bases: MediaElement[ndarray]

classmethod from_file(path: str, *args, **kwargs)[source]#
classmethod from_numpy(data: ndarray | Callable[[], ndarray], *args, **kwargs)[source]#
classmethod from_bytes(data: bytes | Callable[[], bytes], *args, **kwargs)[source]#
property has_size: bool#

Indicates that size info is cached and won’t require image loading

property size: Tuple[int, int] | None#

Returns (H, W)

property ext: str | None#

Media file extension (with the leading dot)

set_crypter(crypter: Crypter)[source]#
class datumaro.plugins.data_formats.arrow.mapper.ImageMapper[source]#

Bases: MediaElementMapper

MEDIA_TYPE = 2#
AVAILABLE_SCHEMES = ('AS-IS', 'PNG', 'TIFF', 'JPEG/95', 'JPEG/75', 'NONE')#
classmethod encode(obj: Image, scheme: str = 'PNG') bytes | None[source]#
classmethod decode(path: str | None = None, data: bytes | None = None) ndarray | None[source]#
classmethod forward(obj: Image, encoder: str | Callable[[Image], bytes] = 'PNG') Dict[str, Any][source]#

Convert an object to bytes.

classmethod backward(media_struct: StructScalar, idx: int, table: Table, table_path: str) Image[source]#

Build an object from bytes.

classmethod backward_extra_image(image_struct: StructScalar, idx: int, table: Table, extra_image_idx: int) Image[source]#
class datumaro.plugins.data_formats.arrow.mapper.Mapper[source]#

Bases: ABC

abstract static forward(obj: Any) bytes[source]#

Convert an object to bytes.

abstract static backward(_bytes: bytes, offset: int = 0) Tuple[Any, int][source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.MediaElement(crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>, *args, **kwargs)[source]#

Bases: Generic[AnyData]

as_dict() Dict[str, Any][source]#
from_self(**kwargs)[source]#
property is_encrypted: bool#
set_crypter(crypter: Crypter)[source]#
property type: MediaType#
property data: AnyData | None#
property has_data: bool#
property bytes: bytes | None#
save(fp: str | ~io.IOBase, crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>)[source]#
class datumaro.plugins.data_formats.arrow.mapper.MediaElementMapper[source]#

Bases: Mapper

MAGIC_PATH = '/NOT/A/REAL/PATH'#
MEDIA_TYPE = 1#
classmethod forward(obj: MediaElement) Dict[str, Any][source]#

Convert an object to bytes.

classmethod backward(media_dict: Dict[str, Any], idx: int, table: Table, table_path: str) MediaElement[source]#

Build an object from bytes.

class datumaro.plugins.data_formats.arrow.mapper.MediaType(value)[source]#

Bases: IntEnum

An enumeration.

NONE = 0#
MEDIA_ELEMENT = 1#
IMAGE = 2#
BYTE_IMAGE = 3#
VIDEO_FRAME = 4#
VIDEO = 5#
POINT_CLOUD = 6#
MULTIFRAME_IMAGE = 7#
ROI_IMAGE = 8#
MOSAIC_IMAGE = 9#
TABLE_ROW = 10#
property media: Type[MediaElement] | None#
class datumaro.plugins.data_formats.arrow.mapper.PointCloud(extra_images: List[Image] | Callable[[], List[Image]] | None = None, *args, **kwargs)[source]#

Bases: MediaElement[bytes]

classmethod from_file(path: str, *args, **kwargs)[source]#
classmethod from_bytes(data: bytes | Callable[[], bytes], *args, **kwargs)[source]#
property extra_images: List[Image]#
class datumaro.plugins.data_formats.arrow.mapper.PointCloudMapper[source]#

Bases: MediaElementMapper

MEDIA_TYPE = 6#
B64_PREFIX = '//B64_ENCODED//'#
classmethod forward(obj: PointCloud, encoder: str | Callable[[PointCloud], bytes] = 'PNG') Dict[str, Any][source]#

Convert an object to bytes.

classmethod backward(media_struct: StructScalar, idx: int, table: Table, table_path: str) PointCloud[source]#

Build an object from bytes.

datumaro.plugins.data_formats.arrow.mapper.decode_image(image_bytes: bytes, dtype: ~numpy.dtype = <class 'numpy.uint8'>) ndarray[source]#
datumaro.plugins.data_formats.arrow.mapper.encode_image(image: np.ndarray, ext: str, dtype: DTypeLike = <class 'numpy.uint8'>, **kwargs) bytes[source]#
datumaro.plugins.data_formats.arrow.mapper.load_image(path: str, dtype: DTypeLike = <class 'numpy.uint8'>, crypter: Crypter = <datumaro.components.crypter.NullCrypter object>)[source]#

Reads an image in the HWC Grayscale/BGR(A) [0; 255] format (default dtype is uint8).

Modules

datumaro.plugins.data_formats.arrow.mapper.dataset_item

datumaro.plugins.data_formats.arrow.mapper.media