otx.data#

Dataclasses and utils for data.

Classes

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

Torch data item batch implementation.

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

Torch data item implementation.

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

Torch prediction data item batch implementation.

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

Torch prediction data item implementation.

class otx.data.TorchDataBatch(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, imgs_info: list[ImageInfo | None] | None = None)[source]#

Bases: ValidateBatchMixin

Torch data item batch implementation.

class otx.data.TorchDataItem(image: torch.Tensor, label: torch.Tensor | None = None, masks: Mask | None = None, bboxes: BoundingBoxes | None = None, keypoints: torch.Tensor | None = None, img_info: ImageInfo | None = None)[source]#

Bases: ValidateItemMixin, Mapping

Torch data item implementation.

image#

The image tensor.

Type:

torch.Tensor

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

img_info#

Additional image information, optional.

Type:

ImageInfo | None

static collate_fn(items: list[TorchDataItem]) TorchDataBatch[source]#

Collate TorchDataItems into a batch.

Parameters:

items – List of TorchDataItems to batch

Returns:

Batched TorchDataItems with stacked tensors

class otx.data.TorchPredBatch(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, imgs_info: list[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: TorchDataBatch

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.TorchPredItem(image: torch.Tensor, label: torch.Tensor | None = None, masks: Mask | None = None, bboxes: BoundingBoxes | None = None, keypoints: torch.Tensor | 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: TorchDataItem

Torch prediction data item implementation.