otx.core.data#

Module for data related objects, such as OTXDataset, OTXDataModule, and Transforms.

Classes

OTXDataModule(task, data_format, data_root, ...)

This class extends the LightningDataModule to provide data handling capabilities for the OTX pipeline.

OTXDatasetFactory()

Factory class for OTXDataset.

TransformLibFactory()

Factory class for transform.

class otx.core.data.OTXDataModule(task: OTXTaskType, data_format: str, data_root: str, train_subset: SubsetConfig, val_subset: SubsetConfig, test_subset: SubsetConfig, tile_config: TileConfig = TileConfig(enable_tiler=False, enable_adaptive_tiling=True, tile_size=(400, 400), overlap=0.2, iou_threshold=0.45, max_num_instances=1500, object_tile_ratio=0.03, sampling_ratio=1.0, with_full_img=False), mem_cache_size: str = '1GB', mem_cache_img_max_size: tuple[int, int] | None = None, image_color_channel: ImageColorChannel = ImageColorChannel.RGB, include_polygons: bool = False, ignore_index: int = 255, unannotated_items_ratio: float = 0.0, auto_num_workers: bool = False, device: DeviceType = DeviceType.auto, input_size: tuple[int, int] | str = 'auto', input_size_multiplier: int = 1)[source]#

Bases: LightningDataModule

This class extends the LightningDataModule to provide data handling capabilities for the OTX pipeline.

Parameters:
  • task (OTXTaskType) – The type of task (e.g., classification, detection).

  • data_format (str) – The format of the data (e.g., ‘coco’, ‘voc’).

  • data_root (str) – The root directory where the data is stored.

  • train_subset (SubsetConfig) – Configuration for the training subset.

  • val_subset (SubsetConfig) – Configuration for the validation subset.

  • test_subset (SubsetConfig) – Configuration for the test subset.

  • tile_config (TileConfig, optional) – Configuration for tiling.

  • TileConfig (Defaults to) –

  • mem_cache_size (str, optional) – Size of the memory cache. Defaults to “1GB”.

  • mem_cache_img_max_size (tuple[int, int] | None, optional) – Maximum size of images in the memory cache.

  • None. (Defaults to) –

  • image_color_channel (ImageColorChannel, optional) – Color channel configuration for images.

  • ImageColorChannel.RGB. (Defaults to) –

  • include_polygons (bool, optional) – Whether to include polygons in the data. Defaults to False.

  • ignore_index (int, optional) – Index to ignore in segmentation tasks. Defaults to 255.

  • unannotated_items_ratio (float, optional) – Ratio of unannotated items to include. Defaults to 0.0.

  • auto_num_workers (bool, optional) – Whether to automatically determine the number of workers. Defaults to False.

  • device (DeviceType, optional) – Device type to use (e.g., ‘cpu’, ‘gpu’). Defaults to DeviceType.auto.

  • input_size (tuple[int, int] | str, optional) – Final image or video shape after transformation.

  • "auto". (Can be "auto" to determine size automatically. Defaults to) –

  • input_size_multiplier (int, optional) – Multiplier for adaptive input size.

  • 1. (Useful for models requiring specific input size multiples. Defaults to) –

Constructor.

predict_dataloader() DataLoader[source]#

Get test dataloader.

setup(stage: str) None[source]#

Setup for each stage.

teardown(stage: str) None[source]#

Teardown for each stage.

test_dataloader() DataLoader[source]#

Get test dataloader.

train_dataloader() DataLoader[source]#

Get train dataloader.

val_dataloader() DataLoader[source]#

Get val dataloader.

property hparams_initial: AttributeDict#

The collection of hyperparameters saved with save_hyperparameters(). It is read-only.

The reason why we override is that we have some custom resolvers for DictConfig. Some resolved Python objects has not a primitive type, so that is not loggable without errors. Therefore, we need to unresolve it this time.

class otx.core.data.OTXDatasetFactory[source]#

Bases: object

Factory class for OTXDataset.

classmethod create(task: OTXTaskType, dm_subset: DmDataset, cfg_subset: SubsetConfig, mem_cache_handler: MemCacheHandlerBase, data_format: str, mem_cache_img_max_size: tuple[int, int] | None = None, image_color_channel: ImageColorChannel = ImageColorChannel.RGB, include_polygons: bool = False, ignore_index: int = 255) OTXDataset[source]#

Create OTXDataset.

class otx.core.data.TransformLibFactory[source]#

Bases: object

Factory class for transform.

classmethod generate(config: SubsetConfig) Transforms[source]#

Create transforms from factory.