otx.data.entity#
Module for OTX data entities.
Classes
|
OTX data item implementation. |
|
Torch data item batch implementation. |
|
Torch prediction data item batch implementation. |
|
Torch prediction data item implementation. |
|
Data entity for detection tile task. |
|
Data entity for segmentation tile task. |
|
Batch data entity for instance segmentation tile task. |
|
Batch data entity for detection tile task. |
|
Batch data entity for semantic segmentation tile task. |
|
Enum to indicate the image type in ImageInfo class. |
|
Meta info for image. |
|
torch.Tensor subclass for points. |
- class otx.data.entity.ImageInfo(img_idx: int, img_shape: tuple[int, int], ori_shape: tuple[int, int], padding: tuple[int, int, int, int] = (0, 0, 0, 0), scale_factor: tuple[float, float] | None = (1.0, 1.0), normalized: bool = False, norm_mean: tuple[float, float, float] = (0.0, 0.0, 0.0), norm_std: tuple[float, float, float] = (1.0, 1.0, 1.0), image_color_channel: ImageColorChannel = ImageColorChannel.RGB, ignored_labels: list[int] | None = None)[source]#
Bases:
TVTensor
Meta info for image.
- img_id#
Image id
- padding#
Number of pixels to pad all borders (left, top, right, bottom)
- scale_factor#
Scale factor (height, width) if the image is resized during preprocessing. Default value is (1.0, 1.0) when there is no resizing. However, if the image is cropped, it will lose the scaling information and be None.
- image_color_channel#
Color channel type of this image, RGB or BGR.
- Type:
otx.types.image.ImageColorChannel
- class otx.data.entity.ImageType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
IntEnum
Enum to indicate the image type in ImageInfo class.
- class otx.data.entity.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.entity.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
- 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.entity.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.
- class otx.data.entity.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.
- class otx.data.entity.Points(data: Any, *, canvas_size: tuple[int, int], dtype: dtype | None = None, device: device | str | int | None = None, requires_grad: bool | None = None)[source]#
Bases:
TVTensor
torch.Tensor subclass for points.
- data#
Any data that can be turned into a tensor with torch.as_tensor.
- canvas_size#
Height and width of the corresponding image or video.
- Type:
two-tuple of ints
- dtype#
Desired data type of the point. If omitted, will be inferred from data.
- Type:
torch.dtype, optional
- device#
Desired device of the point. If omitted and data is a torch.Tensor, the device is taken from it. Otherwise, the point is constructed on the CPU.
- Type:
torch.device, optional
- class otx.data.entity.TileBatchDetDataEntity(batch_size: int, batch_tiles: list[list[tv_tensors.Image]], batch_tile_img_infos: list[list[ImageInfo]], batch_tile_attr_list: list[TileAttrDictList], imgs_info: list[ImageInfo], bboxes: list[tv_tensors.BoundingBoxes], labels: list[LongTensor])[source]#
Bases:
OTXTileBatchDataEntity
Batch data entity for detection tile task.
- classmethod collate_fn(batch_entities: list[TileDetDataEntity]) TileBatchDetDataEntity [source]#
Collate function to collect TileDetDataEntity into TileBatchDetDataEntity in data loader.
- class otx.data.entity.TileBatchInstSegDataEntity(batch_size: int, batch_tiles: list[list[tv_tensors.Image]], batch_tile_img_infos: list[list[ImageInfo]], batch_tile_attr_list: list[TileAttrDictList], imgs_info: list[ImageInfo], bboxes: list[tv_tensors.BoundingBoxes], labels: list[LongTensor], masks: list[tv_tensors.Mask], polygons: list[list[Polygon]])[source]#
Bases:
OTXTileBatchDataEntity
Batch data entity for instance segmentation tile task.
- classmethod collate_fn(batch_entities: list[TileInstSegDataEntity]) TileBatchInstSegDataEntity [source]#
Collate function to collect TileInstSegDataEntity into TileBatchInstSegDataEntity in data loader.
- class otx.data.entity.TileBatchSegDataEntity(batch_size: int, batch_tiles: list[list[Image]], batch_tile_img_infos: list[list[ImageInfo]], batch_tile_attr_list: list[list[dict[str, int | str]]], imgs_info: list[ImageInfo], masks: list[Mask])[source]#
Bases:
OTXTileBatchDataEntity
Batch data entity for semantic segmentation tile task.
- classmethod collate_fn(batch_entities: list[TileSegDataEntity]) TileBatchSegDataEntity [source]#
Collate function to collect TileSegDataEntity into TileBatchSegDataEntity in data loader.
- class otx.data.entity.TileDetDataEntity(num_tiles: int, entity_list: Sequence[OTXDataItem], tile_attr_list: list[dict[str, int | str]], ori_img_info: ImageInfo, ori_bboxes: tv_tensors.BoundingBoxes, ori_labels: LongTensor)[source]#
Bases:
TileDataEntity
Data entity for detection tile task.
- ori_bboxes#
The bounding boxes of the original image.
- Type:
tv_tensors.BoundingBoxes
- ori_labels#
The labels of the original image.
- Type:
LongTensor
- property task: OTXTaskType#
OTX Task type definition.
- class otx.data.entity.TileSegDataEntity(num_tiles: int, entity_list: Sequence[OTXDataItem], tile_attr_list: list[dict[str, int | str]], ori_img_info: ImageInfo, ori_masks: Mask)[source]#
Bases:
TileDataEntity
Data entity for segmentation tile task.
- ori_masks#
The masks of the original image.
- Type:
tv_tensors.Mask
- property task: OTXTaskType#
OTX Task type definition.