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

Minor fix: Update folder dataset + notebooks link #338

Merged
merged 4 commits into from
Jun 1, 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
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ ___

To get an overview of all the devices where `anomalib` as been tested thoroughly, look at the [Supported Hardware](https://openvinotoolkit.github.io/anomalib/#supported-hardware) section in the documentation.

### Jupyter Notebooks

For getting started with a Jupyter Notebook, please refer to the [Notebooks](./notebooks) folder of this repository. Additionally, you can refer to a few created by the community:

- [Google Colab](https://colab.research.google.com/drive/1K4a4z2iZGBNhWdmt9Aqdld7kTAxBfAmi?usp=sharing) by @bth5
- [Kaggle](https://www.kaggle.com/code/ipythonx/mvtec-ad-anomaly-detection-with-anomalib-library) by @innat

### PyPI Install

You can get started with `anomalib` by just using pip.
Expand Down Expand Up @@ -110,18 +117,20 @@ dataset:
name: <name-of-the-dataset>
format: folder
path: <path/to/folder/dataset>
normal: normal # name of the folder containing normal images.
abnormal: abnormal # name of the folder containing abnormal images.
normal_dir: normal # name of the folder containing normal images.
abnormal_dir: abnormal # name of the folder containing abnormal images.
normal_test_dir: null # name of the folder containing normal test images.
task: segmentation # classification or segmentation
mask: <path/to/mask/annotations> #optional
extensions: null
split_ratio: 0.2 # ratio of the normal images that will be used to create a test split
seed: 0
image_size: 256
train_batch_size: 32
test_batch_size: 32
num_workers: 8
transform_config: null
transform_config:
train: null
val: null
create_validation_set: true
tiling:
apply: false
Expand Down
2 changes: 1 addition & 1 deletion anomalib/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_datamodule(config: Union[DictConfig, ListConfig]) -> LightningDataModule
mask_dir=config.dataset.mask,
extensions=config.dataset.extensions,
split_ratio=config.dataset.split_ratio,
seed=config.dataset.seed,
seed=config.project.seed,
image_size=(config.dataset.image_size[0], config.dataset.image_size[1]),
train_batch_size=config.dataset.train_batch_size,
test_batch_size=config.dataset.test_batch_size,
Expand Down
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ omegaconf>=2.1.1
opencv-python>=4.5.3.56
pandas>=1.1.0
pytorch-lightning>=1.6.0
torchmetrics>=0.8.0
torchmetrics==0.8.0
torchvision>=0.9.1
torchtext>=0.9.1
wandb==0.12.9
wandb==0.12.17
matplotlib>=3.4.3
gradio>=2.9.4
61 changes: 34 additions & 27 deletions tests/pre_merge/utils/loggers/test_get_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# See the License for the specific language governing permissions
# and limitations under the License.

from unittest.mock import patch

patch("pytorch_lightning.utilities.imports._package_available", False)
patch("pytorch_lightning.loggers.wandb.WandbLogger")

import pytest
from omegaconf import OmegaConf
from pytorch_lightning.loggers import CSVLogger
Expand All @@ -37,36 +42,38 @@ def test_get_experiment_logger():
}
)

# get no logger
logger = get_experiment_logger(config=config)
assert isinstance(logger, bool)
config.project.logger = False
logger = get_experiment_logger(config=config)
assert isinstance(logger, bool)
with patch("pytorch_lightning.loggers.wandb.wandb"):

# get tensorboard
config.project.logger = "tensorboard"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibTensorBoardLogger)
# get no logger
logger = get_experiment_logger(config=config)
assert isinstance(logger, bool)
config.project.logger = False
logger = get_experiment_logger(config=config)
assert isinstance(logger, bool)

# get wandb logger
config.project.logger = "wandb"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibWandbLogger)
# get tensorboard
config.project.logger = "tensorboard"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibTensorBoardLogger)

# get csv logger.
config.project.logger = "csv"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], CSVLogger)
# get wandb logger
config.project.logger = "wandb"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibWandbLogger)

# get multiple loggers
config.project.logger = ["tensorboard", "wandb", "csv"]
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibTensorBoardLogger)
assert isinstance(logger[1], AnomalibWandbLogger)
assert isinstance(logger[2], CSVLogger)
# get csv logger.
config.project.logger = "csv"
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], CSVLogger)

# raise unknown
with pytest.raises(UnknownLogger):
config.project.logger = "randomlogger"
# get multiple loggers
config.project.logger = ["tensorboard", "wandb", "csv"]
logger = get_experiment_logger(config=config)
assert isinstance(logger[0], AnomalibTensorBoardLogger)
assert isinstance(logger[1], AnomalibWandbLogger)
assert isinstance(logger[2], CSVLogger)

# raise unknown
with pytest.raises(UnknownLogger):
config.project.logger = "randomlogger"
logger = get_experiment_logger(config=config)