Folder Datamodule

Folder Datamodule#

Custom Folder Datamodule for 3D data.

This module provides a custom datamodule for handling 3D data organized in folders. The datamodule supports RGB and depth image pairs for anomaly detection tasks.

Example

Create a folder 3D datamodule:

>>> from anomalib.data import Folder3D
>>> datamodule = Folder3D(
...     name="my_dataset",
...     root="path/to/dataset",
...     normal_dir="normal",
...     abnormal_dir="abnormal"
... )
class anomalib.data.datamodules.depth.folder_3d.Folder3D(name, normal_dir, root, 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, train_batch_size=32, eval_batch_size=32, num_workers=8, train_augmentations=None, val_augmentations=None, test_augmentations=None, augmentations=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: AnomalibDataModule

Folder DataModule for 3D data.

This class extends AnomalibDataModule to handle datasets containing RGB and depth image pairs organized in folders.

Parameters:
  • name (str) – Name of the dataset used for logging and saving.

  • normal_dir (str | Path) – Directory containing normal RGB images.

  • root (str | Path) – Root folder containing normal and abnormal dirs.

  • abnormal_dir (str | Path | None, optional) – Directory containing abnormal RGB images. Defaults to None.

  • normal_test_dir (str | Path | None, optional) – Directory containing normal RGB images for testing. Defaults to None.

  • mask_dir (str | Path | None, optional) – Directory containing mask annotations. Defaults to None.

  • normal_depth_dir (str | Path | None, optional) – Directory containing normal depth images. Defaults to None.

  • abnormal_depth_dir (str | Path | None, optional) – Directory containing abnormal depth images. Defaults to None.

  • normal_test_depth_dir (str | Path | None, optional) – Directory containing normal depth images for testing. If None, uses split from normal_dir. Defaults to None.

  • extensions (tuple[str, ...] | None, optional) – Image file extensions to read. Defaults to None.

  • train_batch_size (int, optional) – Training batch size. Defaults to 32.

  • eval_batch_size (int, optional) – Evaluation batch size. Defaults to 32.

  • num_workers (int, optional) – Number of workers for data loading. Defaults to 8.

  • train_augmentations (Transform | None) – Augmentations to apply dto the training images Defaults to None.

  • val_augmentations (Transform | None) – Augmentations to apply to the validation images. Defaults to None.

  • test_augmentations (Transform | None) – Augmentations to apply to the test images. Defaults to None.

  • augmentations (Transform | None) – General augmentations to apply if stage-specific augmentations are not provided.

  • test_split_mode (TestSplitMode | str, optional) – Method to create test set. Defaults to TestSplitMode.FROM_DIR.

  • test_split_ratio (float, optional) – Fraction of data for testing. Defaults to 0.2.

  • val_split_mode (ValSplitMode | str, optional) – Method to create validation set. Defaults to ValSplitMode.FROM_TEST.

  • val_split_ratio (float, optional) – Fraction of data for validation. Defaults to 0.5.

  • seed (int | None, optional) – Random seed for splitting. Defaults to None.

property name: str#

Get name of the datamodule.

Returns:

Name of the datamodule.

Return type:

str