otx.data#

Dataclasses for data entities.

Classes

OTXDataBatch(batch_size, images[, labels, ...])

Torch data item batch implementation.

OTXDataItem(image[, label, masks, bboxes, ...])

OTX data item implementation.

OTXPredBatch(batch_size, images[, labels, ...])

Torch prediction data item batch implementation.

OTXPredItem(image[, label, masks, bboxes, ...])

Torch prediction data item implementation.

class otx.data.OTXDataBatch(batch_size: int, images: torch.Tensor | list[torch.Tensor], labels: list[torch.Tensor] | None = None, masks: list[Mask] | None = None, bboxes: list[BoundingBoxes] | None = None, keypoints: list[torch.Tensor] | None = None, polygons: list[list[Polygon]] | None = None, imgs_info: Sequence[ImageInfo | None] | None = None)[source]#

Bases: ValidateBatchMixin

Torch data item batch implementation.

pin_memory() OTXDataBatch[source]#

Pin memory for member tensor variables.

wrap(**kwargs) OTXDataBatch[source]#

Wrap this dataclass with the given keyword arguments.

Parameters:

**kwargs – Keyword arguments to be overwritten on top of this dataclass

Returns:

Updated dataclass

class otx.data.OTXDataItem(image: torch.Tensor | np.ndarray, label: torch.Tensor | None = None, masks: Mask | None = None, bboxes: BoundingBoxes | None = None, keypoints: torch.Tensor | None = None, polygons: list[Polygon] | None = None, img_info: ImageInfo | None = None)[source]#

Bases: ValidateItemMixin, Mapping

OTX data item implementation.

image#

The image tensor

Type:

torch.Tensor | np.ndarray

label#

The label tensor, optional.

Type:

torch.Tensor | None

masks#

The masks, optional.

Type:

Mask | None

bboxes#

The bounding boxes, optional.

Type:

BoundingBoxes | None

keypoints#

The keypoints, optional.

Type:

torch.Tensor | None

polygons#

The polygons, optional.

Type:

list[Polygon] | None

img_info#

Additional image information, optional.

Type:

ImageInfo | None

static collate_fn(items: list[OTXDataItem]) OTXDataBatch[source]#

Collate TorchDataItems into a batch.

Parameters:

items – List of TorchDataItems to batch

Returns:

Batched TorchDataItems with stacked tensors

to_tv_image() OTXDataItem[source]#

Return a new instance with the image attribute converted to a TorchVision Image if it is a NumPy array.

Returns:

A new instance with the image attribute converted to a TorchVision Image, if applicable. Otherwise, return this instance as is.

wrap(**kwargs) OTXDataItem[source]#

Wrap this dataclass with the given keyword arguments.

Parameters:

**kwargs – Keyword arguments to be overwritten on top of this dataclass

Returns:

Updated dataclass

class otx.data.OTXPredBatch(batch_size: int, images: torch.Tensor | list[torch.Tensor], labels: list[torch.Tensor] | None = None, masks: list[Mask] | None = None, bboxes: list[BoundingBoxes] | None = None, keypoints: list[torch.Tensor] | None = None, polygons: list[list[Polygon]] | None = None, imgs_info: Sequence[ImageInfo | None] | None = None, scores: list[torch.Tensor] | None = None, feature_vector: list[torch.Tensor] | None = None, saliency_map: list[torch.Tensor] | None = None)[source]#

Bases: OTXDataBatch

Torch prediction data item batch implementation.

property has_xai_outputs: bool#

Check if the batch has XAI outputs.

Necessary for compatibility with tests.

class otx.data.OTXPredItem(image: torch.Tensor | np.ndarray, label: torch.Tensor | None = None, masks: Mask | None = None, bboxes: BoundingBoxes | None = None, keypoints: torch.Tensor | None = None, polygons: list[Polygon] | None = None, img_info: ImageInfo | None = None, scores: torch.Tensor | None = None, feature_vector: torch.Tensor | None = None, saliency_map: torch.Tensor | None = None)[source]#

Bases: OTXDataItem

Torch prediction data item implementation.