Kolektor Datamodule#
Kolektor Surface-Defect Data Module.
- Description:
This script provides a PyTorch DataModule for the Kolektor Surface-Defect dataset. The dataset can be accessed at Kolektor Surface-Defect Dataset.
- License:
The Kolektor Surface-Defect dataset is released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0). For more details, visit Creative Commons License.
- Reference:
Tabernik, Domen, Samo Šela, Jure Skvarč, and Danijel Skočaj. “Segmentation-based deep-learning approach for surface-defect detection.” Journal of Intelligent Manufacturing 31, no. 3 (2020): 759-776.
- class anomalib.data.datamodules.image.kolektor.Kolektor(root='./datasets/kolektor', 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.SAME_AS_TEST, val_split_ratio=0.5, seed=None)#
Bases:
AnomalibDataModuleKolektor Surface-Defect DataModule.
- Parameters:
root (
Path|str|None) – Path to the root of the dataset. Defaults to"./datasets/kolektor".train_batch_size (
int) – Training batch size. Defaults to32.eval_batch_size (
int) – Test batch size. Defaults to32.num_workers (
int) – Number of workers. Defaults to8.train_augmentations (
Transform|None) – Augmentations to apply to the training images Defaults toNone.val_augmentations (
Transform|None) – Augmentations to apply to the validation images. Defaults toNone.test_augmentations (
Transform|None) – Augmentations to apply to the test images. Defaults toNone.augmentations (
Transform|None) – General augmentations to apply if stage-specific augmentations are not provided.test_split_mode (
TestSplitMode|str) – Setting that determines how the testing subset is obtained. Defaults toTestSplitMode.FROM_DIR.test_split_ratio (
float) – Fraction of images from the train set that will be reserved for testing. Defaults to0.2.val_split_mode (
ValSplitMode|str) – Setting that determines how the validation subset is obtained. Defaults toValSplitMode.SAME_AS_TEST.val_split_ratio (
float) – Fraction of train or test images that will be reserved for validation. Defaults to0.5.seed (
int|None) – Seed which may be set to a fixed value for reproducibility.
Example
>>> from anomalib.data import Kolektor >>> datamodule = Kolektor( ... root="./datasets/kolektor", ... train_batch_size=32, ... eval_batch_size=32, ... num_workers=8, ... ) >>> datamodule.setup() >>> i, data = next(enumerate(datamodule.train_dataloader())) >>> data.keys() dict_keys(['image', 'label', 'mask', 'image_path', 'mask_path'])
- prepare_data()#
Download the dataset if not available.
This method checks if the specified dataset is available in the file system. If not, it downloads and extracts the dataset into the appropriate directory.
- Return type:
Example
Assume the dataset is not available on the file system. Here’s how the directory structure looks before and after calling the
prepare_datamethod:Before:
$ tree datasets datasets ├── dataset1 └── dataset2
Calling the method:
>>> datamodule = Kolektor(root="./datasets/kolektor") >>> datamodule.prepare_data()
After:
$ tree datasets datasets ├── dataset1 ├── dataset2 └── kolektor ├── kolektorsdd ├── kos01 ├── ... └── kos50 ├── Part0.jpg ├── Part0_label.bmp └── ...
See also
../../datasets/image/kolektor - Kolektor Dataset