Skip to content

Commit

Permalink
📝 Documentation refactor (#576)
Browse files Browse the repository at this point in the history
* Add benchmark to tutorial

* Move export to tutorials

* Move hpo to tutorials

* Move inference to tutorials

* Move logging to tutorials

* Create installation in tutorials

* Create training to tutorials

* Create tutorials index

* Update conf.py file

* Add anomalib logos to logos directory

* Add data docs

* Add algos

* Add model docs

* Add reference api

* Remove blank line in metrics

* Add reference guide

* Add how to guides

* Add developer guide

* Add blog to how-to-guide

* Remove guides directory

* Add train custom data to how-to-guides

* Fix typos

* Add notebooks to how-to-guides

* Add anomalib favicon

* Add missing algo descriptions

* Rename Reference to Reference Guide

* Add how to add a new model

* fix typos

* Merge PR 544

* Minor refactor (#587)

* 🛠 Fix PatchCore image-level score computation (#580)

* fix patchcore image-level score computation

* docstring and comment

* remove default value for n_neighbors

* torch.Tensor -> Tensor

* Minor refactor

Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Address Dicks comments

Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
  • Loading branch information
4 people committed Sep 27, 2022
1 parent 7d20aa2 commit 598673a
Show file tree
Hide file tree
Showing 78 changed files with 1,507 additions and 969 deletions.
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,38 @@ where the currently available models are:
- [STFPM](anomalib/models/stfpm)
- [GANomaly](anomalib/models/ganomaly)

## Exporting Model to ONNX or OpenVINO IR
## Feature extraction & (pre-trained) backbones

It is possible to export your model to ONNX or OpenVINO IR
The pre-trained backbones come from [PyTorch Image Models (timm)](https://github.com/rwightman/pytorch-image-models), which are wrapped by `FeatureExtractor`.

If you want to export your PyTorch model to an OpenVINO model, ensure that `export_mode` is set to `"openvino"` in the respective model `config.yaml`.
For more information, please check our documentation or the [section about feature extraction in "Getting Started with PyTorch Image Models (timm): A Practitioner’s Guide"](https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055#b83b:~:text=ready%20to%20train!-,Feature%20Extraction,-timm%20models%20also>).

Tips:

- Papers With Code has an interface to easily browse models available in timm: [https://paperswithcode.com/lib/timm](https://paperswithcode.com/lib/timm)

- You can also find them with the function `timm.list_models("resnet*", pretrained=True)`

The backbone can be set in the config file, two examples below.

Anomalib < v.0.4.0

```yaml
optimization:
export_mode: "openvino" # options: openvino, onnx
model:
name: cflow
backbone: wide_resnet50_2
pre_trained: true
Anomalib > v.0.4.0 Beta - Subject to Change
```

Anomalib >= v.0.4.0

```yaml
model:
class_path: anomalib.models.Cflow
init_args:
backbone: wide_resnet50_2
pre_trained: true
```

## Custom Dataset
Expand Down Expand Up @@ -222,6 +245,17 @@ python tools/inference/gradio_inference.py \
--weights ./results/padim/mvtec/bottle/weights/model.ckpt
```

## Exporting Model to ONNX or OpenVINO IR

It is possible to export your model to ONNX or OpenVINO IR

If you want to export your PyTorch model to an OpenVINO model, ensure that `export_mode` is set to `"openvino"` in the respective model `config.yaml`.

```yaml
optimization:
export_mode: "openvino" # options: openvino, onnx
```

# Hyperparameter Optimization

To run hyperparameter optimization, use the following command:
Expand Down
2 changes: 1 addition & 1 deletion anomalib/data/btech.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def __init__(
seed: seed used for the random subset splitting
create_validation_set: Create a validation subset in addition to the train and test subsets
Examples
Examples:
>>> from anomalib.data import BTech
>>> datamodule = BTech(
... root="./datasets/BTech",
Expand Down
2 changes: 2 additions & 0 deletions anomalib/data/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def __init__(
Examples:
Assume that we use Folder Dataset for the MVTec/bottle/broken_large category. We would do:
>>> from anomalib.data import Folder
>>> datamodule = Folder(
... root="./datasets/MVTec/bottle/test",
Expand All @@ -370,6 +371,7 @@ def __init__(
The dataset expects that mask annotation filenames must be same as the original filename.
To this end, we modified mask filenames in MVTec AD bottle category.
Now we could try folder data module using the mvtec bottle broken large category
>>> datamodule = Folder(
... root="./datasets/bottle/test",
... normal="good",
Expand Down
4 changes: 2 additions & 2 deletions anomalib/data/mvtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def make_mvtec_dataset(
MVTec AD dataset does not contain a validation set. Those wanting to create a validation set
could set this flag to ``True``.
Example:
Examples:
The following example shows how to get training samples from MVTec AD bottle category:
>>> root = Path('./MVTec')
Expand Down Expand Up @@ -313,7 +313,7 @@ def __init__(
seed: seed used for the random subset splitting
create_validation_set: Create a validation subset in addition to the train and test subsets
Examples
Examples:
>>> from anomalib.data import MVTec
>>> datamodule = MVTec(
... root="./datasets/MVTec",
Expand Down
272 changes: 0 additions & 272 deletions docs/blog/001-train-custom-dataset/README.md

This file was deleted.

Loading

0 comments on commit 598673a

Please sign in to comment.