Depth Datamodules#
Anomalib Depth Datasets.
- class anomalib.data.depth.Folder3D(normal_dir, root=None, abnormal_dir=None, normal_test_dir=None, mask_dir=None, normal_depth_dir=None, abnormal_depth_dir=None, normal_test_depth_dir=None, extensions=None, image_size=(256, 256), center_crop=None, normalization=InputNormalizationMethod.IMAGENET, train_batch_size=32, eval_batch_size=32, num_workers=8, task=TaskType.SEGMENTATION, transform_config_train=None, transform_config_eval=None, test_split_mode=TestSplitMode.FROM_DIR, test_split_ratio=0.2, val_split_mode=ValSplitMode.FROM_TEST, val_split_ratio=0.5, seed=None)#
Bases:
AnomalibDataModuleFolder DataModule.
- Parameters:
normal_dir (str | Path) – Name of the directory containing normal images.
root (str | Path | None) – Path to the root folder containing normal and abnormal dirs. Defaults to
None.abnormal_dir (str | Path | None) – Name of the directory containing abnormal images. Defaults to
abnormal.normal_test_dir (str | Path | None, optional) – Path to the directory containing normal images for the test dataset. Defaults to
None.mask_dir (str | Path | None, optional) – Path to the directory containing the mask annotations. Defaults to
None.normal_depth_dir (str | Path | None, optional) – Path to the directory containing normal depth images for the test dataset. Normal test depth images will be a split of normal_dir
abnormal_depth_dir (str | Path | None, optional) – Path to the directory containing abnormal depth images for the test dataset.
normal_test_depth_dir (str | Path | None, optional) – Path to the directory containing normal depth images for the test dataset. Normal test images will be a split of normal_dir if None. Defaults to None.
normal_split_ratio (float, optional) – Ratio to split normal training images and add to the test set in case test set doesn’t contain any normal images. Defaults to 0.2.
extensions (tuple[str, ...] | None, optional) – Type of the image extensions to read from the directory. Defaults to None.
image_size (int | tuple[int, int] | None, optional) – Size of the input image. Defaults to None.
center_crop (int | tuple[int, int] | None, optional) – When provided, the images will be center-cropped to the provided dimensions. Defaults to
None.normalization (InputNormalizationMethod | str) – Normalization method to apply to the input images. Defaults to
InputNormalizationMethod.IMAGENET.train_batch_size (int, optional) – Training batch size. Defaults to
32.eval_batch_size (int, optional) – Test batch size. Defaults to
32.num_workers (int, optional) – Number of workers. Defaults to
8.task (TaskType, optional) – Task type. Could be
classification,detectionorsegmentation. Defaults toTaskType.SEGMENTATION.transform_config_train (str | A.Compose | None, optional) – Config for pre-processing during training. Defaults to
None.transform_config_val (str | A.Compose | None, optional) – Config for pre-processing during validation. Defaults to
None.test_split_mode (TestSplitMode) – Setting that determines how the testing subset is obtained. Defaults to
TestSplitMode.FROM_DIR.test_split_ratio (float) – Fraction of images from the train set that will be reserved for testing. Defaults to
0.2.val_split_mode (ValSplitMode) – Setting that determines how the validation subset is obtained. Defaults to
ValSplitMode.FROM_TEST.val_split_ratio (float) – Fraction of train or test images that will be reserved for validation. Defaults to
0.5.seed (int | None, optional) – Seed used during random subset splitting. Defaults to
None.
- class anomalib.data.depth.MVTec3D(root='./datasets/MVTec3D', category='bagel', image_size=(256, 256), center_crop=None, normalization=InputNormalizationMethod.IMAGENET, train_batch_size=32, eval_batch_size=32, num_workers=8, task=TaskType.SEGMENTATION, transform_config_train=None, transform_config_eval=None, test_split_mode=TestSplitMode.FROM_DIR, test_split_ratio=0.2, val_split_mode=ValSplitMode.SAME_AS_TEST, val_split_ratio=0.5, seed=None)#
Bases:
AnomalibDataModuleMVTec Datamodule.
- Parameters:
root (Path | str) – Path to the root of the dataset Defaults to
"./datasets/MVTec3D".category (str) – Category of the MVTec dataset (e.g. “bottle” or “cable”). Defaults to
bagel.image_size (int | tuple[int, int] | None, optional) – Size of the input image. Defaults to
(256, 256).center_crop (int | tuple[int, int] | None, optional) – When provided, the images will be center-cropped to the provided dimensions. Defaults to
None.normalization (InputNormalizationMethod | str) – Normalization method to be applied to the input images. Defaults to
InputNormalizationMethod.IMAGENET.train_batch_size (int, optional) – Training batch size. Defaults to
32.eval_batch_size (int, optional) – Test batch size. Defaults to
32.num_workers (int, optional) – Number of workers. Defaults to
8.task (TaskType) – Task type, ‘classification’, ‘detection’ or ‘segmentation’ Defaults to
TaskType.SEGMENTATION.transform_config_train (str | A.Compose | None, optional) – Config for pre-processing during training. Defaults to None.
transform_config_val (str | A.Compose | None, optional) – Config for pre-processing during validation. Defaults to None.
test_split_mode (TestSplitMode) – Setting that determines how the testing subset is obtained. Defaults to
TestSplitMode.FROM_DIR.test_split_ratio (float) – Fraction of images from the train set that will be reserved for testing. Defaults to
0.2.val_split_mode (ValSplitMode) – Setting that determines how the validation subset is obtained. Defaults to
ValSplitMode.SAME_AS_TEST.val_split_ratio (float) – Fraction of train or test images that will be reserved for validation. Defaults to
0.5.seed (int | None, optional) – Seed which may be set to a fixed value for reproducibility. Defaults to
None.
- prepare_data()#
Download the dataset if not available.
- Return type:
None