Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/data/btad #120

Merged
merged 16 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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