Skip to content

Commit

Permalink
Feature/data/btad (#120)
Browse files Browse the repository at this point in the history
* renamed download-progress-bar as download

* added new download functions to init

* Added Btech data module

* Added btech tests

* Move split functions into a util module

* Modified mvtec

* added btech to get-datamodule

* fix typo in btech docstring

* update docstring

* cleanedup dataset download utils

* Address mypy

* modify config files and update readme.md

* Fix dataset path
  • Loading branch information
samet-akcay authored Mar 15, 2022
1 parent 5f3ee27 commit 539ee6b
Show file tree
Hide file tree
Showing 19 changed files with 645 additions and 145 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
run: pip install tox
- name: Coverage
run: |
export ANOMALIB_DATASET_PATH=/media/data1/datasets/MVTec
export ANOMALIB_DATASET_PATH=/media/data1/datasets/
export CUDA_VISIBLE_DEVICES=2
tox -e nightly
- name: Upload coverage result
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: tox -e black,isort,flake8,pylint,mypy,pydocstyle
- name: Coverage
run: |
export ANOMALIB_DATASET_PATH=/media/data1/datasets/MVTec
export ANOMALIB_DATASET_PATH=/media/data1/datasets/
export CUDA_VISIBLE_DEVICES=3
tox -e pre_merge
- name: Upload coverage result
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project related
datasets
!anomalib/datasets
!tests/datasets
!tests/pre_merge/datasets
results
!anomalib/core/results

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ python tools/inference.py \
___

## Datasets
The `development` branch supports MVTec and BeanTech datasets.

### [MVTec Dataset](https://www.mvtec.com/company/research/datasets/mvtec-ad)

Expand Down
20 changes: 18 additions & 2 deletions anomalib/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from omegaconf import DictConfig, ListConfig
from pytorch_lightning import LightningDataModule

from .btech import BTechDataModule
from .inference import InferenceDataset
from .mvtec import MVTecDataModule

Expand All @@ -34,7 +35,7 @@ def get_datamodule(config: Union[DictConfig, ListConfig]) -> LightningDataModule
"""
datamodule: LightningDataModule

if config.dataset.format.lower() == "mvtec":
if config.dataset.name.lower() == "mvtec":
datamodule = MVTecDataModule(
# TODO: Remove config values. IAAALD-211
root=config.dataset.path,
Expand All @@ -45,8 +46,23 @@ def get_datamodule(config: Union[DictConfig, ListConfig]) -> LightningDataModule
num_workers=config.dataset.num_workers,
seed=config.project.seed,
)
elif config.dataset.name.lower() == "btech":
datamodule = BTechDataModule(
# TODO: Remove config values. IAAALD-211
root=config.dataset.path,
category=config.dataset.category,
image_size=(config.dataset.image_size[0], config.dataset.image_size[0]),
train_batch_size=config.dataset.train_batch_size,
test_batch_size=config.dataset.test_batch_size,
num_workers=config.dataset.num_workers,
seed=config.project.seed,
)
else:
raise ValueError("Unknown dataset!")
raise ValueError(
"Unknown dataset! \n"
"If you use a custom dataset make sure you initialize it in"
"`get_datamodule` in `anomalib.data.__init__.py"
)

return datamodule

Expand Down
Loading

0 comments on commit 539ee6b

Please sign in to comment.