From 7edb6af2db9dd142815e5fbc61c57232adbb347e Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Mon, 25 Mar 2024 13:13:04 +0200 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=93=9A=20Add=20action=20to=20check=20?= =?UTF-8?q?broken=20links=20(#1838)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix broken links * Add link checker * Fix link in template * linter * nightly check --------- Co-authored-by: Samet Akcay --- .github/pull_request_template.md | 2 +- .github/workflows/nightly.yml | 7 ++++++ .github/workflows/pre_merge.yml | 8 ++++++ CONTRIBUTING.md | 4 +-- README.md | 10 ++++---- .../markdown/announcements/recognition.md | 2 +- docs/source/markdown/get_started/anomalib.md | 2 +- notebooks/100_datamodules/README.md | 12 ++++----- notebooks/500_use_cases/501_dobot/README.md | 4 +-- notebooks/README.md | 25 +++++++------------ pyproject.toml | 10 ++++++++ src/anomalib/models/image/cfa/README.md | 8 +++--- src/anomalib/models/image/cflow/README.md | 8 +++--- src/anomalib/models/image/csflow/README.md | 6 ++--- src/anomalib/models/image/draem/README.md | 2 +- src/anomalib/models/image/dsr/README.md | 2 +- src/anomalib/models/image/fastflow/README.md | 8 +++--- src/anomalib/models/image/ganomaly/README.md | 2 +- src/anomalib/models/image/padim/README.md | 8 +++--- src/anomalib/models/image/patchcore/README.md | 8 +++--- .../image/reverse_distillation/README.md | 8 +++--- src/anomalib/models/image/stfpm/README.md | 8 +++--- src/anomalib/models/image/uflow/README.md | 20 +++++++-------- src/anomalib/models/image/winclip/README.md | 2 +- 24 files changed, 97 insertions(+), 79 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bbc1ee7043..ed786b426b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -22,4 +22,4 @@ Before you submit your pull request, please make sure you have completed the fol - [ ] 📚 I have made the necessary updates to the documentation (if applicable). - [ ] 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable). -For more information about code review checklists, see the [Code Review Checklist](../docs/source/markdown/guides/developer/code_review_checklist.md). +For more information about code review checklists, see the [Code Review Checklist](https://github.com/openvinotoolkit/anomalib/blob/main/docs/source/markdown/guides/developer/code_review_checklist.md). diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4cc09c4a3b..20f5f07db0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -23,3 +23,10 @@ jobs: with: name: coverage path: .tox/coverage.xml + md-dead-link-check: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: AlexanderDokuchaev/md-dead-link-check@v0.7 + with: + config: pyproject.toml diff --git a/.github/workflows/pre_merge.yml b/.github/workflows/pre_merge.yml index 27135835db..8f11eecf28 100644 --- a/.github/workflows/pre_merge.yml +++ b/.github/workflows/pre_merge.yml @@ -75,3 +75,11 @@ jobs: else ./codecov -t "${CODECOV_TOKEN}" --sha $COMMIT_ID -U $HTTP_PROXY -f .tox/coverage.xml fi + + md-dead-link-check: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: AlexanderDokuchaev/md-dead-link-check@v0.7 + with: + config: pyproject.toml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 143aab11b7..33117aef09 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ However, make sure to address any pre-commit issues before finalizing your pull ### Making Changes -1. **Write Code:** Follow the project's coding standards and write your code with clear intent. Ensure your code is well-documented and includes examples where appropriate. For code quality we use ruff, whose configuration is in [`pyproject.toml`](https://github.com/openvinotoolkit/anomalib/blob/main/pyproject.toml) file. +1. **Write Code:** Follow the project's coding standards and write your code with clear intent. Ensure your code is well-documented and includes examples where appropriate. For code quality we use ruff, whose configuration is in [`pyproject.toml`](pyproject.toml) file. 2. **Add Tests:** If your code includes new functionality, add corresponding tests using [pytest](https://docs.pytest.org/en/7.4.x/) to maintain coverage and reliability. @@ -99,7 +99,7 @@ However, make sure to address any pre-commit issues before finalizing your pull pytest tests/ ``` -5. **Update the Changelog:** For significant changes, add a summary to the [CHANGELOG](https://github.com/openvinotoolkit/anomalib/blob/main/CHANGELOG.md). +5. **Update the Changelog:** For significant changes, add a summary to the [CHANGELOG](CHANGELOG.md). 6. **Check Licensing:** Ensure you own the code or have rights to use it, adhering to appropriate licensing. diff --git a/README.md b/README.md index 88c9ee5532..dcf87dfc87 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [Key Features](#key-features) • [Docs](https://anomalib.readthedocs.io/en/latest/) • [Notebooks](notebooks) • -[License](https://github.com/openvinotoolkit/anomalib/blob/main/LICENSE) +[License](LICENSE) [![python](https://img.shields.io/badge/python-3.7%2B-green)]() [![pytorch](https://img.shields.io/badge/pytorch-1.8.1%2B-orange)]() @@ -52,7 +52,7 @@ Installing the library with pip is the easiest way to get started with anomalib. pip install anomalib ``` -This will install Anomalib CLI using the [installer](requirements/installer.txt) dependecies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command: +This will install Anomalib CLI using the [installer](requirements/installer.txt) dependencies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command: ```bash # Get help for the installation arguments @@ -78,7 +78,7 @@ anomalib install --option openvino To install from source, you need to clone the repository and install the library using pip via editable mode. ```bash -# Use of virtual environment is highy recommended +# Use of virtual environment is highly recommended # Using conda yes | conda create -n anomalib_env python=3.10 conda activate anomalib_env @@ -92,7 +92,7 @@ cd anomalib pip install -e . ``` -This will install Anomalib CLI using the [installer](requirements/installer.txt) dependecies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command: +This will install Anomalib CLI using the [installer](requirements/installer.txt) dependencies. Anomalib CLI is a command line interface for training, inference, benchmarking, and hyperparameter optimization. If you want to use the library as a Python package, you can install the library with the following command: ```bash # Get help for the installation arguments @@ -259,7 +259,7 @@ You first need to modify the `config.yaml` file to enable logging. The following Anomalib provides a benchmarking tool to evaluate the performance of the anomaly detection models on a given dataset. The benchmarking tool can be used to evaluate the performance of the models on a given dataset, or to compare the performance of multiple models on a given dataset. -Each model in anomalib is benchmarked on a set of datasets, and the results are available in `src/anomalib/models/README.md`. For example, the MVTec AD results for the Patchcore model are available in the corresponding [README.md](https://github.com/openvinotoolkit/anomalib/tree/main/src/anomalib/models/patchcore#mvtec-ad-dataset) file. +Each model in anomalib is benchmarked on a set of datasets, and the results are available in `src/anomalib/models///README.md`. For example, the MVTec AD results for the Patchcore model are available in the corresponding [README.md](src/anomalib/models/image/patchcore/README.md#mvtec-ad-dataset) file.
Benchmarking via API diff --git a/docs/source/markdown/announcements/recognition.md b/docs/source/markdown/announcements/recognition.md index c9547d9234..7eaf05c690 100644 --- a/docs/source/markdown/announcements/recognition.md +++ b/docs/source/markdown/announcements/recognition.md @@ -11,7 +11,7 @@ Anomalib is committed to excellence and innovation in open-source software devel [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8330/badge)](https://www.bestpractices.dev/projects/8330) - **Date:** January 25, 2024 -- **Details:** Anomalib recived the passing grade for the [Open Source Initiative Best Practices Badge](https://opensource.org/best-practices-badge). This badge recognizes our commitment to high-quality coding standards and community engagement. +- **Details:** Anomalib received the passing grade for the [Open Source Initiative Best Practices Badge](https://opensource.org/best-practices-badge). This badge recognizes our commitment to high-quality coding standards and community engagement. [Learn more about this award](https://opensource.org/best-practices-badge) ::: diff --git a/docs/source/markdown/get_started/anomalib.md b/docs/source/markdown/get_started/anomalib.md index 3bf32a0890..37af563b3e 100644 --- a/docs/source/markdown/get_started/anomalib.md +++ b/docs/source/markdown/get_started/anomalib.md @@ -253,7 +253,7 @@ By using the configuration file above, you can run the experiment with the follo Anomalib provides a benchmarking tool to evaluate the performance of the anomaly detection models on a given dataset. The benchmarking tool can be used to evaluate the performance of the models on a given dataset, or to compare the performance of multiple models on a given dataset. -Each model in anomalib is benchmarked on a set of datasets, and the results are available in `src/anomalib/models/README.md`. For example, the MVTec AD results for the Patchcore model are available in the corresponding [README.md](https://github.com/openvinotoolkit/anomalib/tree/main/src/anomalib/models/patchcore#mvtec-ad-dataset) file. +Each model in anomalib is benchmarked on a set of datasets, and the results are available in `src/anomalib/models/README.md`. For example, the MVTec AD results for the Patchcore model are available in the corresponding [README.md](https://github.com/openvinotoolkit/anomalib/tree/main/src/anomalib/models/image/patchcore#mvtec-ad-dataset) file. ::::{tab-set} diff --git a/notebooks/100_datamodules/README.md b/notebooks/100_datamodules/README.md index 600c94b0e6..0fd1a4049b 100644 --- a/notebooks/100_datamodules/README.md +++ b/notebooks/100_datamodules/README.md @@ -1,11 +1,11 @@ # Anomalib DataModules Tutorial -| Notebook | GitHub | Colab | -| -------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| BTech | [101_btech](100_datamodules/101_btech.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/101_btech.ipynb) | -| MVTec | [102_mvtec](100_datamodules/102_mvtec.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/102_mvtec.ipynb) | -| Folder | [103_folder](100_datamodules/103_folder.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/103_folder.ipynb) | -| Tiling | [104_tiling](100_datamodules/104_tiling.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/104_tiling.ipynb) | +| Notebook | GitHub | Colab | +| -------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| BTech | [101_btech](101_btech.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/101_btech.ipynb) | +| MVTec | [102_mvtec](102_mvtec.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/102_mvtec.ipynb) | +| Folder | [103_folder](103_folder.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/103_folder.ipynb) | +| Tiling | [104_tiling](104_tiling.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/100_datamodules/104_tiling.ipynb) | ## Notebook Contents diff --git a/notebooks/500_use_cases/501_dobot/README.md b/notebooks/500_use_cases/501_dobot/README.md index 289a6c15ff..724c57473b 100644 --- a/notebooks/500_use_cases/501_dobot/README.md +++ b/notebooks/500_use_cases/501_dobot/README.md @@ -54,9 +54,9 @@ d. Then, replace those coordinates in the notebook ### Data acquisition and inferencing -For data acquisition and inferencing we will use [501b notebook](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/500_use_cases/501_dobot/501_dobot/501b_inference_with_a_robotic_arm.ipynb). There we need to identify the `acquisition` flag, **True** for _acquisition mode_ and **False** for _inferencing mode_. In acquisition mode be aware of the _normal_ or _abnormal_ folder we want to create, in this mode the notebook will save every image in the anomalib/datasets/cubes/{FOLDER} for further training. In inferencing mode the notebook won't save images, it will run the inference and show the results. +For data acquisition and inferencing we will use [501b notebook](501b_inference_with_a_robotic_arm.ipynb). There we need to identify the `acquisition` flag, **True** for _acquisition mode_ and **False** for _inferencing mode_. In acquisition mode be aware of the _normal_ or _abnormal_ folder we want to create, in this mode the notebook will save every image in the anomalib/datasets/cubes/{FOLDER} for further training. In inferencing mode the notebook won't save images, it will run the inference and show the results. -_Note_: If you dont have the robot you could jump to the another notebook [501a](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/500_use_cases/501_dobot/501a_training_a_model_with_cubes_from_a_robotic_arm.ipynb) and download the dataset from this [link](https://github.com/openvinotoolkit/anomalib/releases/tag/dobot) +_Note_: If you dont have the robot you could jump to the another notebook [501a](501a_training_a_model_with_cubes_from_a_robotic_arm.ipynb) and download the dataset from this [link](https://github.com/openvinotoolkit/anomalib/releases/tag/dobot) ### Training diff --git a/notebooks/README.md b/notebooks/README.md index cfa08b6f61..36976a6855 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -39,22 +39,15 @@ To install Python, Git and other required tools, [OpenVINO Notebooks](https://gi | -------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Model | [201_fastflow](200_models/201_fastflow.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/200_models/201_fastflow.ipynb) | -## 3. Benchmarking and Hyperparameter Optimization +## 3. OpenVINO Optimization -| Notebook | GitHub | Colab | -| -------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Benchmarking | [301_benchmarking](300_benchmarking/301_benchmarking.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/300_benchmarking/301_benchmarking.ipynb) | -| HPO with wandb | [302_hpo_wandb](300_benchmarking/302_hpo_wandb.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openvinotoolkit/anomalib/blob/main/notebooks/300_benchmarking/302_hpo_wandb.ipynb) | +| Notebook | GitHub | Colab | +| ------------ | -------------------------------------------------- | ----- | +| Quantization | [401_NNCF](/notebooks/400_openvino/401_nncf.ipynb) | | -## 4. OpenVINO Optimization +## 4. Use cases -| Notebook | GitHub | Colab | -| ------------ | ------------------------------------------------------------------------------------------------------- | ----- | -| Quantization | [401_NNCF](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/400_openvino/401_nncf.ipynb) | | - -## 3. Use cases - -| Notebook | GitHub | Colab | -| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- | -| Dobot Dataset Creation | [501a_training](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/500_use_cases/501_dobot/501a_training_a_model_with_cubes_from_a_robotic_arm.ipynb) | | -| Training | [501b_training](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/500_use_cases/501_dobot/501b_inference_with_a_robotic_arm.ipynb) | | +| Notebook | GitHub | Colab | +| ---------------------- | ------------------------------------------------------------------------------------------------------------- | ----- | +| Dobot Dataset Creation | [501a_training](/notebooks/500_use_cases/501_dobot/501a_training_a_model_with_cubes_from_a_robotic_arm.ipynb) | | +| Training | [501b_training](/notebooks/500_use_cases/501_dobot/501b_inference_with_a_robotic_arm.ipynb) | | diff --git a/pyproject.toml b/pyproject.toml index 2d44364e19..8cd34a9d13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -246,3 +246,13 @@ source = ["src", ".tox/*/site-packages"] # NBQA CONFIGURATION # [tool.nbqa.addopts] ruff = ["--ignore=E402"] + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# LINK CHECKER CONFIGURATION # +[tool.md_dead_link_check] +exclude_links = [ + "https://github.com/openvinotoolkit/anomalib/settings/actions/runners/new", + "https://openvinotoolkit.github.io/anomalib/*", # Remove it after publish documentation +] +exclude_files = ["docs/*"] +force_get_requests_for_links = ["https://secure.ethicspoint.com/*"] diff --git a/src/anomalib/models/image/cfa/README.md b/src/anomalib/models/image/cfa/README.md index 927ca2ce15..d174bfe26f 100755 --- a/src/anomalib/models/image/cfa/README.md +++ b/src/anomalib/models/image/cfa/README.md @@ -12,7 +12,7 @@ Coupled-hypersphere-based Feature Adaptation (CFA) localizes anomalies using fea ## Architecture -![Cfa Architecture](../../../../../docs/source/images/cfa/architecture.png "Cfa Architecture") +![Cfa Architecture](/docs/source/images/cfa/architecture.png "Cfa Architecture") ## Usage @@ -139,11 +139,11 @@ When the numbers are produced, early stopping callback (patience: 5) is used. It ### Sample Results -![Sample Result 1](../../../../../docs/source/images/cfa/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/cfa/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/cfa/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/cfa/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/cfa/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/cfa/results/2.png "Sample Result 3") ## Reference diff --git a/src/anomalib/models/image/cflow/README.md b/src/anomalib/models/image/cflow/README.md index 34a9a9ec48..b9345e3e99 100644 --- a/src/anomalib/models/image/cflow/README.md +++ b/src/anomalib/models/image/cflow/README.md @@ -10,7 +10,7 @@ CFLOW model is based on a conditional normalizing flow framework adopted for ano ## Architecture -![CFlow Architecture](../../../../../docs/source/images/cflow/architecture.jpg "CFlow Architecture") +![CFlow Architecture](/docs/source/images/cflow/architecture.jpg "CFlow Architecture") ## Usage @@ -42,8 +42,8 @@ All results gathered with seed `42`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/cflow/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/cflow/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/cflow/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/cflow/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/cflow/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/cflow/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/csflow/README.md b/src/anomalib/models/image/csflow/README.md index 952f8c678a..ab979ddfee 100644 --- a/src/anomalib/models/image/csflow/README.md +++ b/src/anomalib/models/image/csflow/README.md @@ -23,11 +23,11 @@ The anomaly score for each local position $(i,j)$ of the feature map $y^s$ at sc ## Architecture -![CS-Flow Architecture](../../../../../docs/source/images/cs_flow/architecture1.jpg "CS-Flow Architecture") +![CS-Flow Architecture](/docs/source/images/cs_flow/architecture1.jpg "CS-Flow Architecture") -![Architecture of a Coupling Block](../../../../../docs/source/images/cs_flow/architecture2.jpg "Architecture of a Coupling Block") +![Architecture of a Coupling Block](/docs/source/images/cs_flow/architecture2.jpg "Architecture of a Coupling Block") -![Architecture of network predicting scale and shift parameters.](../../../../../docs/source/images/cs_flow/architecture3.jpg "Architecture of network predicting scale and shift parameters.") +![Architecture of network predicting scale and shift parameters.](/docs/source/images/cs_flow/architecture3.jpg "Architecture of network predicting scale and shift parameters.") ## Usage diff --git a/src/anomalib/models/image/draem/README.md b/src/anomalib/models/image/draem/README.md index 501c3ca1b9..007faa0220 100644 --- a/src/anomalib/models/image/draem/README.md +++ b/src/anomalib/models/image/draem/README.md @@ -12,7 +12,7 @@ For optimal results, DRAEM requires specifying the path to a folder of image dat ## Architecture -![DRAEM Architecture](../../../../../docs/source/images/draem/architecture.png "DRAEM Architecture") +![DRAEM Architecture](/docs/source/images/draem/architecture.png "DRAEM Architecture") ## Usage diff --git a/src/anomalib/models/image/dsr/README.md b/src/anomalib/models/image/dsr/README.md index cfb057c205..fcf330817d 100644 --- a/src/anomalib/models/image/dsr/README.md +++ b/src/anomalib/models/image/dsr/README.md @@ -10,7 +10,7 @@ DSR is a quantized-feature based algorithm that consists of an autoencoder with ## Architecture -![DSR Architecture](../../../../../docs/source/images/dsr/architecture.png "DSR Architecture") +![DSR Architecture](/docs/source/images/dsr/architecture.png "DSR Architecture") ## Usage diff --git a/src/anomalib/models/image/fastflow/README.md b/src/anomalib/models/image/fastflow/README.md index b7edd7e8da..9dfc7dda65 100644 --- a/src/anomalib/models/image/fastflow/README.md +++ b/src/anomalib/models/image/fastflow/README.md @@ -10,7 +10,7 @@ FastFlow is a two-dimensional normalizing flow-based probability distribution es ## Architecture -![FastFlow Architecture](../../../../../docs/source/images/fastflow/architecture.jpg "FastFlow Architecture") +![FastFlow Architecture](/docs/source/images/fastflow/architecture.jpg "FastFlow Architecture") ## Usage @@ -110,8 +110,8 @@ All results gathered with seed `0`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/fastflow/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/fastflow/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/fastflow/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/fastflow/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/fastflow/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/fastflow/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/ganomaly/README.md b/src/anomalib/models/image/ganomaly/README.md index 36cf4bf87c..9ffa5376f3 100644 --- a/src/anomalib/models/image/ganomaly/README.md +++ b/src/anomalib/models/image/ganomaly/README.md @@ -12,7 +12,7 @@ The key idea here is that, during inference, when an anomalous image is passed t ## Architecture -![GANomaly Architecture](../../../../../docs/source/images/ganomaly/architecture.jpg "GANomaly Architecture") +![GANomaly Architecture](/docs/source/images/ganomaly/architecture.jpg "GANomaly Architecture") ## Usage diff --git a/src/anomalib/models/image/padim/README.md b/src/anomalib/models/image/padim/README.md index dc2566e966..35aaeec995 100644 --- a/src/anomalib/models/image/padim/README.md +++ b/src/anomalib/models/image/padim/README.md @@ -12,7 +12,7 @@ During inference, Mahalanobis distance is used to score each patch position of t ## Architecture -![PaDiM Architecture](../../../../../docs/source/images/padim/architecture.jpg "PaDiM Architecture") +![PaDiM Architecture](/docs/source/images/padim/architecture.jpg "PaDiM Architecture") ## Usage @@ -47,8 +47,8 @@ All results gathered with seed `42`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/padim/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/padim/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/padim/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/padim/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/padim/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/padim/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/patchcore/README.md b/src/anomalib/models/image/patchcore/README.md index f19229418b..9d49ffd6f8 100644 --- a/src/anomalib/models/image/patchcore/README.md +++ b/src/anomalib/models/image/patchcore/README.md @@ -12,7 +12,7 @@ During inference this memory bank is coreset subsampled. Coreset subsampling gen ## Architecture -![PatchCore Architecture](../../../../../docs/source/images/patchcore/architecture.jpg "PatchCore Architecture") +![PatchCore Architecture](/docs/source/images/patchcore/architecture.jpg "PatchCore Architecture") ## Usage @@ -47,8 +47,8 @@ All results gathered with seed `42`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/patchcore/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/patchcore/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/patchcore/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/patchcore/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/patchcore/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/patchcore/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/reverse_distillation/README.md b/src/anomalib/models/image/reverse_distillation/README.md index daeae5d2f8..8b22685f41 100644 --- a/src/anomalib/models/image/reverse_distillation/README.md +++ b/src/anomalib/models/image/reverse_distillation/README.md @@ -12,7 +12,7 @@ During testing, a similar step is followed but this time the cosine distance bet ## Architecture -![Anomaly Detection via Reverse Distillation from One-Class Embedding Architecture](../../../../../docs/source/images/reverse_distillation/architecture.png "Reverse Distillation Architecture") +![Anomaly Detection via Reverse Distillation from One-Class Embedding Architecture](/docs/source/images/reverse_distillation/architecture.png "Reverse Distillation Architecture") ## Usage @@ -44,8 +44,8 @@ All results gathered with seed `42`, train batch size `16`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/reverse_distillation/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/reverse_distillation/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/reverse_distillation/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/reverse_distillation/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/reverse_distillation/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/reverse_distillation/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/stfpm/README.md b/src/anomalib/models/image/stfpm/README.md index 1920e24667..6b83dad775 100644 --- a/src/anomalib/models/image/stfpm/README.md +++ b/src/anomalib/models/image/stfpm/README.md @@ -12,7 +12,7 @@ During inference, the feature pyramids of teacher and student networks are compa ## Architecture -![STFPM Architecture](../../../../../docs/source/images/stfpm/architecture.jpg "STFPM Architecture") +![STFPM Architecture](/docs/source/images/stfpm/architecture.jpg "STFPM Architecture") ## Usage @@ -47,8 +47,8 @@ All results gathered with seed `42`. ### Sample Results -![Sample Result 1](../../../../../docs/source/images/stfpm/results/0.png "Sample Result 1") +![Sample Result 1](/docs/source/images/stfpm/results/0.png "Sample Result 1") -![Sample Result 2](../../../../../docs/source/images/stfpm/results/1.png "Sample Result 2") +![Sample Result 2](/docs/source/images/stfpm/results/1.png "Sample Result 2") -![Sample Result 3](../../../../../docs/source/images/stfpm/results/2.png "Sample Result 3") +![Sample Result 3](/docs/source/images/stfpm/results/2.png "Sample Result 3") diff --git a/src/anomalib/models/image/uflow/README.md b/src/anomalib/models/image/uflow/README.md index 6bd840664a..eafe769f50 100644 --- a/src/anomalib/models/image/uflow/README.md +++ b/src/anomalib/models/image/uflow/README.md @@ -4,7 +4,7 @@ This is the implementation of the [U-Flow](https://www.researchsquare.com/article/rs-3367286/latest) paper, based on the [original code](https://www.github.com/mtailanian/uflow) -![U-Flow Architecture](../../../../../docs/source/images/uflow/diagram.png "U-Flow Architecture") +![U-Flow Architecture](/docs/source/images/uflow/diagram.png "U-Flow Architecture") ## Abstract @@ -14,17 +14,17 @@ This multiple-hypothesis testing strategy permits the derivation of robust autom The segmentation results are evaluated using the Intersection over Union (IoU) metric, and for assessing the generated anomaly maps we report the area under the Receiver Operating Characteristic curve (AUROC), and the area under the per-region-overlap curve (AUPRO). Extensive experimentation in various datasets shows that the proposed approach produces state-of-the-art results for all metrics and all datasets, ranking first in most MvTec-AD categories, with a mean pixel-level AUROC of 98.74%._ -![Teaser image](../../../../../docs/source/images/uflow/teaser.jpg) +![Teaser image](/docs/source/images/uflow/teaser.jpg) ## Localization results ### Pixel AUROC over MVTec-AD Dataset -![Pixel-AUROC results](../../../../../docs/source/images/uflow/pixel-auroc.png "Pixel-AUROC results") +![Pixel-AUROC results](/docs/source/images/uflow/pixel-auroc.png "Pixel-AUROC results") ### Pixel AUPRO over MVTec-AD Dataset -![Pixel-AUPRO results](../../../../../docs/source/images/uflow/pixel-aupro.png "Pixel-AUPRO results") +![Pixel-AUPRO results](/docs/source/images/uflow/pixel-aupro.png "Pixel-AUPRO results") ## Segmentation results (IoU) with threshold log(NFA)=0 @@ -32,11 +32,11 @@ This paper also proposes a method to automatically compute the threshold using t In the default code here, for the sake of comparison with all the other methods of the library, the segmentation is done computing the threshold over the anomaly map at train time. Nevertheless, the code for computing the segmentation mask with the NFA criterion is included in the `src/anomalib/models/uflow/anomaly_map.py`. -![IoU results](../../../../../docs/source/images/uflow/iou.png "IoU results") +![IoU results](/docs/source/images/uflow/iou.png "IoU results") ## Results over other datasets -![Results over other datasets](../../../../../docs/source/images/uflow/more-results.png "Results over other datasets") +![Results over other datasets](/docs/source/images/uflow/more-results.png "Results over other datasets") ## Benchmarking @@ -111,18 +111,18 @@ Normalizing Flow outputs #### MVTec -![MVTec results - anomalies](../../../../../docs/source/images/uflow/results-mvtec-anomalies.jpg "MVTec results - anomalies") +![MVTec results - anomalies](/docs/source/images/uflow/results-mvtec-anomalies.jpg "MVTec results - anomalies") #### BeanTech, LGG MRI, STC -![BeanTech, LGG MRI, STC results - anomalies](../../../../../docs/source/images/uflow/results-others-anomalies.jpg "BeanTech, LGG MRI, STC results - anomalies") +![BeanTech, LGG MRI, STC results - anomalies](/docs/source/images/uflow/results-others-anomalies.jpg "BeanTech, LGG MRI, STC results - anomalies") ### Normal images #### MVTec -![MVTec results - normal](../../../../../docs/source/images/uflow/results-mvtec-good.jpg "MVTec results - normal") +![MVTec results - normal](/docs/source/images/uflow/results-mvtec-good.jpg "MVTec results - normal") #### BeanTech, LGG MRI, STC -![BeanTech, LGG MRI, STC results - normal](../../../../../docs/source/images/uflow/results-others-good.jpg "BeanTech, LGG MRI, STC results - normal") +![BeanTech, LGG MRI, STC results - normal](/docs/source/images/uflow/results-others-good.jpg "BeanTech, LGG MRI, STC results - normal") diff --git a/src/anomalib/models/image/winclip/README.md b/src/anomalib/models/image/winclip/README.md index 16f4b30270..24a1fa8e4e 100644 --- a/src/anomalib/models/image/winclip/README.md +++ b/src/anomalib/models/image/winclip/README.md @@ -14,7 +14,7 @@ In few-shot mode, a reference association module is introduced, which collects a ## Architecture -![WinCLIP Architecture](../../../../../docs/source/images/winclip/architecture.png "WinCLIP Architecture") +![WinCLIP Architecture](/docs/source/images/winclip/architecture.png "WinCLIP Architecture") ## Usage From 8ebfdf5097f3d07b91039a2b69977aac71186efb Mon Sep 17 00:00:00 2001 From: TurboJonte Date: Mon, 25 Mar 2024 14:01:43 +0100 Subject: [PATCH 2/7] Use LabelName ENUM for label assignment (#1881) * Use LabelName ENUM for label assignment * Update src/anomalib/deploy/inferencers/torch_inferencer.py Co-authored-by: Samet Akcay --------- Co-authored-by: Samet Akcay --- src/anomalib/deploy/inferencers/torch_inferencer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/anomalib/deploy/inferencers/torch_inferencer.py b/src/anomalib/deploy/inferencers/torch_inferencer.py index ee5a3f2e71..b7eef88058 100644 --- a/src/anomalib/deploy/inferencers/torch_inferencer.py +++ b/src/anomalib/deploy/inferencers/torch_inferencer.py @@ -15,6 +15,7 @@ from torch import nn from anomalib import TaskType +from anomalib.data import LabelName from anomalib.data.utils import read_image from anomalib.data.utils.boxes import masks_to_boxes from anomalib.utils.visualization import ImageResult @@ -282,10 +283,10 @@ def post_process( # Common practice in anomaly detection is to assign anomalous # label to the prediction if the prediction score is greater # than the image threshold. - pred_label: str | None = None + pred_label: LabelName | None = None if "image_threshold" in metadata: pred_idx = pred_score >= metadata["image_threshold"] - pred_label = "Anomalous" if pred_idx else "Normal" + pred_label = LabelName.ABNORMAL if pred_idx else LabelName.NORMAL pred_mask: np.ndarray | None = None if "pixel_threshold" in metadata: From 6be4c802396ce7aa393f89a60d141f739dc867e3 Mon Sep 17 00:00:00 2001 From: TurboJonte Date: Mon, 25 Mar 2024 14:02:27 +0100 Subject: [PATCH 3/7] Changed prediction label assignment for OpenVINO inferencer (#1872) * Update openvino_inferencer.py Fixed incorrect label assignment. Was True/False, now it's "Anomalous/Normal" as for the PyTorch inferencer in torch_inferencer.py * Fix ruff --------- Co-authored-by: Samet --- src/anomalib/deploy/inferencers/openvino_inferencer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/anomalib/deploy/inferencers/openvino_inferencer.py b/src/anomalib/deploy/inferencers/openvino_inferencer.py index 98cb2e498c..db0d966fad 100644 --- a/src/anomalib/deploy/inferencers/openvino_inferencer.py +++ b/src/anomalib/deploy/inferencers/openvino_inferencer.py @@ -15,6 +15,7 @@ from PIL import Image from anomalib import TaskType +from anomalib.data.utils.label import LabelName from anomalib.utils.visualization import ImageResult from .base_inferencer import Inferencer @@ -253,7 +254,7 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No # Initialize the result variables. anomaly_map: np.ndarray | None = None - pred_label: float | None = None + pred_label: LabelName | None = None pred_mask: float | None = None # If predictions returns a single value, this means that the task is @@ -270,7 +271,8 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No # label to the prediction if the prediction score is greater # than the image threshold. if "image_threshold" in metadata: - pred_label = pred_score >= metadata["image_threshold"] + pred_idx = pred_score >= metadata["image_threshold"] + pred_label = LabelName.ABNORMAL if pred_idx else LabelName.NORMAL if task == TaskType.CLASSIFICATION: _, pred_score = self._normalize(pred_scores=pred_score, metadata=metadata) From 5588d3fdf7a4b0590934f032cccd557b08c32270 Mon Sep 17 00:00:00 2001 From: Bepitic Date: Sun, 24 Mar 2024 21:09:46 +0100 Subject: [PATCH 4/7] Add: fix image transform to float Signed-off-by: Bepitic --- src/anomalib/data/base/video.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/anomalib/data/base/video.py b/src/anomalib/data/base/video.py index 7e9461a0a9..b632498aab 100644 --- a/src/anomalib/data/base/video.py +++ b/src/anomalib/data/base/video.py @@ -153,6 +153,7 @@ def __getitem__(self, index: int) -> dict[str, str | torch.Tensor]: msg = "self.indexer must be an instance of ClipsIndexer." raise TypeError(msg) item = self.indexer.get_item(index) + item["image"] = item["image"].to(torch.float32) # include the untransformed image for visualization item["original_image"] = item["image"].to(torch.uint8) From 7be9ec39ad4821c507e966ec01140d1670657f34 Mon Sep 17 00:00:00 2001 From: Bepitic Date: Mon, 25 Mar 2024 18:44:22 +0100 Subject: [PATCH 5/7] upd: video dtpe transform from torchvision Signed-off-by: Bepitic --- src/anomalib/data/base/video.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/anomalib/data/base/video.py b/src/anomalib/data/base/video.py index b632498aab..4272a7e665 100644 --- a/src/anomalib/data/base/video.py +++ b/src/anomalib/data/base/video.py @@ -10,6 +10,7 @@ import torch from pandas import DataFrame from torchvision.transforms.v2 import Transform +from torchvision.transforms.v2.functional._misc import to_dtype_video from torchvision.tv_tensors import Mask from anomalib import TaskType @@ -153,7 +154,7 @@ def __getitem__(self, index: int) -> dict[str, str | torch.Tensor]: msg = "self.indexer must be an instance of ClipsIndexer." raise TypeError(msg) item = self.indexer.get_item(index) - item["image"] = item["image"].to(torch.float32) + item["image"] = to_dtype_video(item["image"]) # include the untransformed image for visualization item["original_image"] = item["image"].to(torch.uint8) From 2d8fa9281ef9ab74e30b458901ff822c4dff6132 Mon Sep 17 00:00:00 2001 From: Bepitic Date: Mon, 25 Mar 2024 19:02:44 +0100 Subject: [PATCH 6/7] Added the scale. Signed-off-by: Bepitic --- src/anomalib/data/base/video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anomalib/data/base/video.py b/src/anomalib/data/base/video.py index 4272a7e665..18275b4536 100644 --- a/src/anomalib/data/base/video.py +++ b/src/anomalib/data/base/video.py @@ -154,7 +154,7 @@ def __getitem__(self, index: int) -> dict[str, str | torch.Tensor]: msg = "self.indexer must be an instance of ClipsIndexer." raise TypeError(msg) item = self.indexer.get_item(index) - item["image"] = to_dtype_video(item["image"]) + item["image"] = to_dtype_video(video=item["image"], scale=True) # include the untransformed image for visualization item["original_image"] = item["image"].to(torch.uint8) From f79181add7477aedfb766037164f03e42fa38f47 Mon Sep 17 00:00:00 2001 From: Samet Akcay Date: Tue, 26 Mar 2024 08:44:32 +0000 Subject: [PATCH 7/7] Update src/anomalib/data/base/video.py Co-authored-by: Dick Ameln --- src/anomalib/data/base/video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anomalib/data/base/video.py b/src/anomalib/data/base/video.py index 18275b4536..f2882e18a4 100644 --- a/src/anomalib/data/base/video.py +++ b/src/anomalib/data/base/video.py @@ -10,7 +10,7 @@ import torch from pandas import DataFrame from torchvision.transforms.v2 import Transform -from torchvision.transforms.v2.functional._misc import to_dtype_video +from torchvision.transforms.v2.functional import to_dtype_video from torchvision.tv_tensors import Mask from anomalib import TaskType