AutoVI Datamodule#
AutoVI Data Module.
This module provides a PyTorch Lightning DataModule for the AutoVI (Automotive Visual Inspection) dataset.
The dataset is hosted on Zenodo as six independent zip files — one per
class. When AutoVI.prepare_data() is called, only the zip file that
corresponds to the requested category is downloaded and extracted, so you
don’t have to fetch the full 4 GB archive if you only need one class.
Usage:
from anomalib.data.datamodules.image import AutoVI
datamodule = AutoVI(
root="./datasets/AutoVI",
category="pipe_clip",
train_batch_size=32,
eval_batch_size=32,
num_workers=8,
)
datamodule.setup()
for batch in datamodule.train_dataloader():
print(batch["image"].shape) # (32, 3, H, W)
- Data License:
Copyright © 2023-2024 Renault Group. Released under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). https://creativecommons.org/licenses/by-nc-sa/4.0/
- Reference:
Carvalho, P., Lafou, M., Durupt, A., Leblanc, A., & Grandvalet, Y. (2024). The Automotive Visual Inspection Dataset (AutoVI): A Genuine Industrial Production Dataset for Unsupervised Anomaly Detection [Dataset]. https://doi.org/10.5281/zenodo.10459003
- class anomalib.data.datamodules.image.autovi.AutoVI(root=None, category='engine_wiring', 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:
AnomalibDataModuleAutoVI Lightning DataModule.
Downloads (on demand) and wraps the AutoVI dataset for use with the anomalib training engine. Because the dataset ships as six separate zip files, only the zip that belongs to the requested
categoryis fetched.The resulting on-disk layout mirrors MVTec AD, except that ground-truth masks are stored one level deeper — each mask lives in a subdirectory named after the corresponding test image stem:
datasets/ └── AutoVI/ ├── engine_wiring/ │ ├── train/good/*.png │ ├── test/{good,<defect_type>}/*.png │ └── ground_truth/<defect_type>/<image_stem>/0000.png ├── pipe_clip/ ├── pipe_staple/ ├── tank_screw/ ├── underbody_pipes/ └── underbody_screw/For example, the mask for
test/unclipped/0089.pngis stored atground_truth/unclipped/0089/0000.png.- Parameters:
root (
Path|str|None) – Root directory that will contain (or already contains) the per-category sub-directories. Defaults toNone→<anomalib_datasets_dir>/AutoVI.category (
str) – One of the six AutoVI classes. Defaults to"engine_wiring".train_batch_size (
int) – Training batch size. Defaults to32.eval_batch_size (
int) – Validation / test batch size. Defaults to32.num_workers (
int) – Number of DataLoader workers. Defaults to8.train_augmentations (
Transform|None) – Augmentations for the training split. Defaults toNone.val_augmentations (
Transform|None) – Augmentations for the validation split. Defaults toNone.test_augmentations (
Transform|None) – Augmentations for the test split. Defaults toNone.augmentations (
Transform|None) – Fallback augmentations used when no split-specific augmentation is supplied. Defaults toNone.test_split_mode (
TestSplitMode|str) – How to obtain the test set. Defaults toTestSplitMode.FROM_DIR.test_split_ratio (
float) – Fraction of data to use for testing. Defaults to0.2.val_split_mode (
ValSplitMode|str) – How to obtain the validation set. Defaults toValSplitMode.SAME_AS_TEST.val_split_ratio (
float) – Fraction of data to use for validation. Defaults to0.5.seed (
int|None) – Random seed for reproducibility. Defaults toNone.
Example
>>> datamodule = AutoVI( ... root="./datasets/AutoVI", ... category="pipe_clip", ... ) >>> datamodule.setup() >>> i, batch = next(enumerate(datamodule.train_dataloader())) >>> batch["image"].shape torch.Size([32, 3, 256, 256])
- prepare_data()#
Download and extract the zip for the requested category, if needed.
Only the single zip that belongs to
self.categoryis fetched from Zenodo — the remaining five classes are left untouched.The check is: if
<root>/<category>/already exists as a directory we assume the data are present and skip the download.- Return type:
Example
>>> datamodule = AutoVI( ... root="./datasets/AutoVI", ... category="tank_screw", ... ) >>> datamodule.prepare_data() # downloads tank_screw.zip only
Directory structure after a successful download:
datasets/ └── AutoVI/ ├── engine_wiring/ │ ├── train/good/*.png │ ├── test/{good,<defect_type>}/*.png │ └── ground_truth/<defect_type>/<image_stem>/0000.png