Bases: AnomalyDataModule
Standard anomaly datamodule with automatic download of the MVTec dataset.
Source code in quadra/datamodules/generic/mvtec.py
| def __init__(self, data_path: str, category: str, **kwargs):
if category not in DATASET_URL:
raise ValueError(f"Unknown category {category}. Available categories are {list(DATASET_URL.keys())}")
super().__init__(data_path=data_path, category=category, **kwargs)
|
download_data()
Download the MVTec dataset.
Source code in quadra/datamodules/generic/mvtec.py
41
42
43
44
45
46
47
48
49
50
51
52
53 | def download_data(self) -> None:
"""Download the MVTec dataset."""
if self.category is None:
raise ValueError("Category must be specified for MVTec dataset.")
if os.path.exists(self.data_path):
log.info("The path %s already exists. Skipping download.", os.path.join(self.data_path, self.category))
return
log.info("Downloading and extracting MVTec dataset for category %s to %s", self.category, self.data_path)
# self.data_path is the path to the category folder that will be created by the download_and_extract_archive
data_path_no_category = str(Path(self.data_path).parent)
download_and_extract_archive(DATASET_URL[self.category], data_path_no_category, remove_finished=True)
|