otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset#
Visual Prompting Dataset & DataModule.
Functions
|
Convert polygon to mask. |
|
Generate bounding box. |
|
Generate bounding box from given mask. |
|
Get transform pipeline. |
Classes
|
Visual Prompting DataModule. |
|
Visual Prompting Dataset Adaptor. |
|
Visual Prompting for Zero-shot learning Dataset Adaptor. |
- class otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.OTXVisualPromptingDataModule(config: DictConfig | ListConfig, dataset: DatasetEntity, train_type: TrainType = TrainType.Incremental)[source]#
Bases:
LightningDataModule
Visual Prompting DataModule.
- Parameters:
config (Union[DictConfig, ListConfig]) – Configuration.
dataset (DatasetEntity) – Dataset entity.
- prepare_data_per_node#
If True, each LOCAL_RANK=0 will call prepare data. Otherwise only NODE_RANK=0, LOCAL_RANK=0 will prepare data.
- allow_zero_length_dataloader_with_multiple_devices#
If True, dataloader with zero length within local rank is allowed. Default value is False.
- predict_dataloader() DataLoader [source]#
Predict Dataloader.
- Returns:
Predict Dataloader.
- Return type:
DataLoader
- setup(stage: str | None = None) None [source]#
Setup Visual Prompting Data Module.
- Parameters:
stage (Optional[str], optional) – train/val/test stages, defaults to None.
- test_dataloader() DataLoader [source]#
Test Dataloader.
- Returns:
Test Dataloader.
- Return type:
DataLoader
- class otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.OTXVisualPromptingDataset(mode: Subset, dataset: DatasetEntity, image_size: int, mean: List[float], std: List[float], offset_bbox: int = 0, use_point: bool = False, use_bbox: bool = False)[source]#
Bases:
Dataset
Visual Prompting Dataset Adaptor.
- Parameters:
dataset (DatasetEntity) – Dataset entity.
image_size (int) – Target size to resize image.
mean (List[float]) – Mean for normalization.
std (List[float]) – Standard deviation for normalization.
offset_bbox (int) – Offset to apply to the bounding box, defaults to 0.
- static get_prompts(dataset_item: DatasetItemEntity, dataset_labels: List[LabelEntity], prob: float = 1.0, mode: Subset = Subset.TESTING) Dict[str, Any] [source]#
Get propmts from dataset_item.
- Parameters:
dataset_item (DatasetItemEntity) – Dataset item entity.
dataset_labels (List[LabelEntity]) – Label information.
prob (float) – Probability of which prompts will be generated.
mode (Subset) – To check which mode is used between training, validation, and testing.
- Returns:
Processed prompts with ground truths.
- Return type:
Dict[str, Any]
- class otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.OTXZeroShotVisualPromptingDataset(mode: Subset, dataset: DatasetEntity, image_size: int, mean: List[float], std: List[float], offset_bbox: int = 0, use_point: bool = False, use_bbox: bool = False)[source]#
Bases:
OTXVisualPromptingDataset
Visual Prompting for Zero-shot learning Dataset Adaptor.
- otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.convert_polygon_to_mask(shape: Polygon, width: int, height: int) ndarray [source]#
Convert polygon to mask.
- otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.generate_bbox(x1: int, y1: int, x2: int, y2: int, width: int, height: int, offset_bbox: int = 0) List[int] [source]#
Generate bounding box.
- Parameters:
x1 (int) – Bounding box coordinates. # type: ignore
y1 (int) – Bounding box coordinates. # type: ignore
x2 (int) – Bounding box coordinates. # type: ignore
y2 (int) – Bounding box coordinates. # type: ignore
width (int) – Width of image.
height (int) – Height of image.
offset_bbox (int) – Offset to apply to the bounding box, defaults to 0.
- Returns:
Generated bounding box.
- Return type:
List[int]
- otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.generate_bbox_from_mask(gt_mask: ndarray, width: int, height: int) List[int] [source]#
Generate bounding box from given mask.
- otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset.get_transform(image_size: int = 1024, mean: List[float] = [123.675, 116.28, 103.53], std: List[float] = [58.395, 57.12, 57.375]) MultipleInputsCompose [source]#
Get transform pipeline.
- Parameters:
- Returns:
Transform pipeline.
- Return type: