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

Add DSR model #1142

Merged
merged 63 commits into from
Oct 24, 2023
Merged

Add DSR model #1142

merged 63 commits into from
Oct 24, 2023

Conversation

phcarval
Copy link
Contributor

@phcarval phcarval commented Jun 16, 2023

Description

Changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which refactors the code base)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the pre-commit style and check guidelines of this project.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have added a summary of my changes to the CHANGELOG (not for minor changes, docs and tests).

@github-actions github-actions bot added the Docs label Jun 16, 2023
@phcarval
Copy link
Contributor Author

Added automatic pretrained weight downloading. Now the model can train on its own, but the third phase of training is still missing.
These additions would benefit from being integrated to download.py (as well as the anomaly generator should be added to the already existing files... but this is more complex since DSR has its own way of generating anomalies).

@phcarval
Copy link
Contributor Author

I tested the DSR model by loading the authors' pretrained weights and finding the exact same results as them. The following changes are necessary to reproduce :

  • load_state_dict() for each module in DsrModel.__init__()
  • normalization: none in config.yaml
  • normalization_method: none in config.yaml
  • eval batch size is 1
  • comment image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) in data/utils/image.py
  • set weight_file to None in test.py

Still training left to test as well as implementing the third phase of training.

@phcarval
Copy link
Contributor Author

Training seems to work on my end. Only thing left to implement is the upsampling module.

@samet-akcay
Copy link
Contributor

I fixed it using manual optimization. However, it doesn't improve maintainability and perhaps it should be changed if we find a way to make it work using core Lightning functionality.

Thanks for the fix @phcarval! I agree with @blaz-r. Your solution also shows that this could be done manually via vanilla torch, which demonstrates flexibility. I think it would be a good example to some users/developers for future implementations.

@phcarval
Copy link
Contributor Author

I fixed it using manual optimization. However, it doesn't improve maintainability and perhaps it should be changed if we find a way to make it work using core Lightning functionality.

Thanks for the fix @phcarval! I agree with @blaz-r. Your solution also shows that this could be done manually via vanilla torch, which demonstrates flexibility. I think it would be a good example to some users/developers for future implementations.

Thanks for the feedback! My concern was that, AFAIK, it is the only method that uses a different optimization system in Anomalib and so it could create somewhat of an issue down the line if the method is refactored, as optimization is supposed to be "automatic" in Lightning. It's probably a very minor problem though.

Anyway, I have no more outstanding issues on my end!

Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phcarval, this is a huge PR :)

I've got some minor comments, but the overall code quality is quite high! Thanks again for your contribution and patience!

docs/source/reference_guide/algorithms/dsr.rst Outdated Show resolved Hide resolved
src/anomalib/models/dsr/README.md Outdated Show resolved Hide resolved
src/anomalib/models/dsr/config.yaml Outdated Show resolved Hide resolved
src/anomalib/models/dsr/config.yaml Show resolved Hide resolved
src/anomalib/models/dsr/lightning_model.py Outdated Show resolved Hide resolved
src/anomalib/models/dsr/torch_model.py Outdated Show resolved Hide resolved
src/anomalib/models/dsr/torch_model.py Outdated Show resolved Hide resolved
- Computed segmentation mask (M)
- Resized ground-truth anomaly map (M_gt)
"""
# top == lo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left over?

src/anomalib/models/dsr/torch_model.py Outdated Show resolved Hide resolved
"embedding_top": embd_top,
"obj_spec_image": spec_image_def,
"pred_mask": out_mask_sm,
"true_mask": anomaly_map,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is anomaly_map really a true_mask?

@samet-akcay
Copy link
Contributor

By the way, there is one failed test, mainly because DsrModel returns a dict. We probably need a separate PR to handle torch outputs that are dict

@phcarval
Copy link
Contributor Author

I went though all requested changes @samet-akcay !

Comment on lines 169 to 170
batch["anomaly_maps"] = model_outputs["pred_mask"]
batch["pred_scores"] = model_outputs["score"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible if model_outputs have the same keys for anomaly_maps and pred_scores? The reason for asking is that we need standard keys for the TorchInferencer stuff?

The tests are failing since the output model is returning a different output than what is expected here

def post_process(self, predictions: Tensor, metadata: dict | DictConfig | None = None) -> dict[str, Any]:
"""Post process the output predictions.
Args:
predictions (Tensor): Raw output predicted by the model.
metadata (dict, optional): Meta data. Post-processing step sometimes requires
additional meta data such as image shape. This variable comprises such info.
Defaults to None.
Returns:
dict[str, str | float | np.ndarray]: Post processed prediction results.
"""
if metadata is None:
metadata = self.metadata
if isinstance(predictions, Tensor):
anomaly_map = predictions.detach().cpu().numpy()
pred_score = anomaly_map.reshape(-1).max()
else:
# NOTE: Patchcore `forward`` returns heatmap and score.
# We need to add the following check to ensure the variables
# are properly assigned. Without this check, the code
# throws an error regarding type mismatch torch vs np.
if isinstance(predictions[1], (Tensor)):
anomaly_map, pred_score = predictions
anomaly_map = anomaly_map.detach().cpu().numpy()
pred_score = pred_score.detach().cpu().numpy()
else:
anomaly_map, pred_score = predictions
pred_score = pred_score.detach()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have create PR #1354 to handle cases like this. DsrModel needs to return anomaly_map and pred_score though.

@phcarval
Copy link
Contributor Author

phcarval commented Oct 2, 2023

@samet-akcay have you had the time to test the model? I seem to have very bad segmentation results, this might be due to the optimizer change. I would like to know if you had that problem too.

@phcarval
Copy link
Contributor Author

phcarval commented Oct 5, 2023

When removing the default imagenet normalization parameter, training seems to be going much better and my results are close to the paper's. Only problem is the one I describe in issue #1380 where images are segmented even if they're classified as non-anomalous.

@phcarval
Copy link
Contributor Author

When removing the default imagenet normalization parameter, training seems to be going much better and my results are close to the paper's. Only problem is the one I describe in issue #1380 where images are segmented even if they're classified as non-anomalous.

Actually, this is not a problem since DSR outputs a score that does not depend on the final segmentation map. I believe all outstanding issues are solved now :)

Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phcarval, looking great! Really appreciate your patience, and thanks again for this great contribution!

@samet-akcay samet-akcay merged commit 8a7f1d6 into openvinotoolkit:main Oct 24, 2023
2 of 4 checks passed
@phcarval phcarval deleted the dsr_dev branch October 30, 2023 11:50
samet-akcay added a commit that referenced this pull request Jan 23, 2024
* Address tiler issues (#1411)

* fix tiler

* deprecate random tile locations

* restore random tiling in tile method

* check tiling section in config

* disable tiling for ganomalu

* pad -> padding

* Refactor Reverse Distillation to match official code (#1389)

* Non-mandatory early stopping

* Added conv4 and bn4 to OCBE

* Loss as in the official code (flattened arrays)

* Added comment on how to use torchvision model as an encoder to reproduce results in the paper

* Remove early stop from config, change default anomaly_map_mode to add

* pre-commit fix

* Updated results

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Remove early_stopping

* Update src/anomalib/models/reverse_distillation/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Easier to read code

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Patch for the WinError183 on the OpenVino export mode (#1386)

* Fix WinError183 (Windows Error)

* Add commentary of the change

---------

Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>

* Add DSR model (#1142)

* added license, init.py and draft readme

* added draft DSR files

* minor comment update

* Implemented dsr model + comments

* added dsr discrete model

* added defect generation in torch model + dsr to list of existing methods in init.py

* fixed torch model, started implementing lightning model, implemented anomaly generator

* added loss file for DSR

* Added loss, improved lightning module

* Finished up global implementation of DSR second phase

* minor fixes

* Bugfixes

* Fixed DSR loss calculation

* on_training_start -> on_train_start

* pre-commit run

* updated DSR documentation

* reset config file

* added automatic pretraining weight download

* testing pretrained weights. fixed embedding size in upsampling module and image recon module, to be fixed in original branch

* successful testing on pretrained dsr weights

* checked test quality with pretrained weights, fixed anomaly score calculation

* training is functional

* Fixed training procedure

* test still working

* working upsampling module training and testing

* fixed minor bugs

* updated documentation

* added tests and doc

* adapted learning schedule to steps

* Update src/anomalib/models/dsr/anomaly_generator.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactored outputs into dicts

* remove super() args

* changed downloading weights from anomalib releases + minor fixes

* pre commit hooks + minor fixes

* removed configurable ckpt path refs + default iteration nb from paper

* cleaned up dsr.rst and turned exceptions into RuntimeErrors

* Added upsampling ratio parameter to set third training phase epochs

* Added batched evalaution + minor code simplification

* pre commit hooks

* squeeze output image score tensor

* readded new path check in efficient ad

* fixed double step count with manual optimization

* fixed trailing whitespace

* Fix black issues

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* review suggestions

* updated architecture image links

* Address mypy

* changed output types for dsr model

* readded dict outputs, adapted to TorchInferencer

* fixed error in output dict

* removed default imagenet norm

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fix unexpected key pixel_metrics.AUPRO.fpr_limit (#1055)

* fix unexpected key pixel_metrics.AUPRO.fpr_limit

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* load AUPRO before create_metric_collection

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* code refine

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix comment

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* Support test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Improved speed and memory usage of mean+std calculation (#1457)

* preexisting OpenCV version check added to `setup.py`, ran formatting pre-commit hooks on previous contribution. (#1424)

* testing upstream switch

* picked up on stale OpenCV `setup.py` issue #1041

* 🐞 Hotfix: Limit Gradio Version (#1458)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Fix/efficient ad normalize before every validation (#1441)

* Normalize anomaly maps before every validation

* Remove print statement

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Fix DRAEM (#1431)

* Fix beta in augmenter

* Add scheduler

* Change normalization to none

* Replace two lr schedulers with MultiStepLR

* Revert change to beta

* Disable early stopping default

* Format config

* Add opacity parameter beta to config

* Adding U-Flow method (#1415)

* Added uflow model

* Added documentation (README) for uflow model

* Added uflow to the list of available models, and main README updated

* Added missing images for the documentation

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/feature_extraction.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Added uflow to the reference guide in docs

* Added uflow to the pre-merge tests

* removed the _step function, and merged the code with training_step

* added as a comment the values used in the paper

* re-factorized feature extractors to use the TimmFeatureExtractor class

* added annotations for some functions, where the flow graph is created

* updated readme to fix images loading

* Added link in the README to the original code for reproducing the results

* Removed unused kwargs

* Added docstrigs with args explanations to UFlow classes

* Added models in a github release, and linked here

* Passing all pre-commit checks

* Changed freia's AllInOneBlock by Anomalib's version, and converted the subnet contructor to a Class, in order to be pickable, that is needed to export the model to torch

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update README.md

* 📘 Announce anomalib v1 on the main `README.md` (#1542)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Announce anomalib v1 on readme

* Add the installation instructions and update the documentation link

* Fixed DSR (#1486)

* fixed DSR squeeze bug

* added comment

* Refactor/extensions custom dataset (#1562)

* Explanation how to use extension names in the config file

* Added information about extensions to the error message and control of the user input

* Easier to read code

* Replacing assert with raise

* 📚 Modify the PR template (#1611)

Update pull_request_template.md

* Fix result image URLs (#1510)

* Fix tests

* refactor path + fix issues + fix linting issues

* Migrate docs

* fix typing

* fix failing model tests

* Fix tests

* Address PR comments

* Fixed shape error, allowing arbitary image sizes for EfficientAD (#1537)

* Fixed shape error, allowing arbitrary image sizes. Replaced integer parsing by floor operation

* Replaced calculation by ceil operation. Solution of shape error is to round up and not down for the last upsample layer

* Add comment for ceil oepration

* Formatting with pre-commit hook

* Clean up badge

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: ggiret-thinkdeep <146845847+ggiret-thinkdeep@users.noreply.github.com>
Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>
Co-authored-by: Philippe Carvalho <31983398+phcarval@users.noreply.github.com>
Co-authored-by: Wenjing Kang <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: belfner <belfner@belfner.com>
Co-authored-by: Abdulla Al Blooshi <76493346+abdullamatar@users.noreply.github.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Matías Tailanian <895687+mtailanian@users.noreply.github.com>
Co-authored-by: Jan Schlüter <github@jan-schlueter.de>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Christopher <48522299+holzweber@users.noreply.github.com>
samet-akcay added a commit that referenced this pull request Jan 24, 2024
* Merge feature/lightning-version-upgrade to feature/custom-trainer (#1297)

Upgrade to Lightning 2.0.5 (#1221)

* Adapt code and configs to PL 2.0.5

* Pre-commit checks.

* Fix a function call.

* Fix function calls.

* pytorch_lightning -> lightning.pytorch

* Add lightning to requirements

---------

Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Samet <samet.akcay@intel.com>

* Partially restore tests (#1298)

* Upgrade to Lightning 2.0.5 (#1221)

* Adapt code and configs to PL 2.0.5

* Pre-commit checks.

* Fix a function call.

* Fix function calls.

* pytorch_lightning -> lightning.pytorch

* Add lightning to requirements

---------

Co-authored-by: Samet <samet.akcay@intel.com>

* partially restore tests

* Address PR comments

---------

Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Samet <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Remove future annotations (#1299)

* remove __future__

* Update changelog

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Refactor postprocessing (#1302)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Remove handler

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] refactor normalization callbacks (#1310)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

---------

* [Custom Trainer] Refactor thresholding (#1311)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [Custom Trainer] Refactor Metrics (#1312)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Refactor metrics configuration

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Refactor visualization callback (#1313)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Refactor metrics configuration

* Move visualizer callbacks into trainer

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Remove comment

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Initial engine design (#1348)

* Initial engine design

* Address PR comments

* Circular import + trainer->engine

* Update src/anomalib/engine/engine.py

* revert import in __init__

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [Custom Trainer] Partially fix tests (#1359)

* Partially fix test

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Add CLI support (#1381)

* Support trainer methods

* support yaml serialization

* add hpo command

* Add benchmark + train entrypoint

* Add export arguments

* Partially address PR comments

* Add export subcommands + refactor

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Partially restore tests (#1391)

* Fix tests

* Patch get experiment logger

* Sort imports

* Add stfpm config

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add new ruff rules (#1390)

* Add rules to pyproject.toml file

* Only include padim and stfpm in tests

* Fix notebook tests

* Fix notebook tests

* Code quality/enable rules (#1394)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* Enable Ruff rules - Part III (#1397)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* Enable Ruff Rules - Part 4 (#1402)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* [Custom Trainer] Switch to manual optimization for ganomaly (#1404)

* implement manual optimizers for ganomaly

* cleanup

* Enable Ruff Rules - Part 5 (#1403)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* Update src/anomalib/models/components/flow/all_in_one_block.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* addressed pr comments

---------

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* [Custom Trainer] Add import checks (#1393)

* Add checks

* Add checks for wandb

* move exception handling to method

* fix pre-commit issue

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Remove max epochs > 1 (#1400)

Remove max epochs>1 from default param list

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Add default values (#1395)

* Add checks

* Add default values to datasets + padim model

* update default values

* Remove merge artifact

* Change gt path

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Enable Ruff Rules - Part 6 (#1407)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* Enable Ruff Rules - Part 7 (#1408)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* Fix random_split tests

* Fix pre-commit

* Fixed the logger test

* Fix the typos in todos

* Enable Ruff Rules - Part 8 (#1412)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Enable Ruff Rules - Part 9 (#1419)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Update src/anomalib/utils/metrics/binning.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update src/anomalib/models/dfkde/lightning_model.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update src/anomalib/models/rkde/feature_extractor.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fixed pre-commit

---------

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Merge main into feature/custom_trainer (#1420)

* Address tiler issues (#1411)

* fix tiler

* deprecate random tile locations

* restore random tiling in tile method

* check tiling section in config

* disable tiling for ganomalu

* pad -> padding

* Refactor Reverse Distillation to match official code (#1389)

* Non-mandatory early stopping

* Added conv4 and bn4 to OCBE

* Loss as in the official code (flattened arrays)

* Added comment on how to use torchvision model as an encoder to reproduce results in the paper

* Remove early stop from config, change default anomaly_map_mode to add

* pre-commit fix

* Updated results

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Remove early_stopping

* Update src/anomalib/models/reverse_distillation/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Easier to read code

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Enable Ruff Rules - Part 10 (#1423)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Enabled "PLW2901",  # `for` loop variable `row` overwritten by assignment target

* Enable Ruff Rules - Part 11 (#1425)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Enabled "PLW2901",  # `for` loop variable `row` overwritten by assignment target

* Add google style to pydocstyle

* Remove dashed line from Returns

* Remove dashed line from Args

* Remove dashed line from Example and Raises

* Removed left-over dashed lines

* Cleanup pyproject.toml file

* [Custom Trainer] Add a verbose help output structure to the CLI (#1396)

* Add Verbosity Help-Formatter class

* Add Help-Formatter unit-tests

* Fix some strings

* Fix pre-commit ruff stuff

* Fix help_formatter's pre-commit

* Add new configs (#1418)

* Add new configs

* Add draem config

* Fix docstring

* Update src/anomalib/models/cflow/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Linting

* Remove --- from docstrings

* Remove any from return type

* Fix linting issues from feature/custom_trainer

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Add CLI Tests (#1426)

* Add new configs

* Add draem config

* Stash cli tests

* Stash cli tests with minor changes

* Stash changes

* Fix reverse distillation

* Fix EfficientAD

* Match ai_vad params to config params

* Fix ucsd and ai_vad configs

* Uncomment validation step

* Refactor directory structure

* Rename method

* use uscd for aivad

* fix ucsd path + modify model checkpoint callback for tests

* fix dfkde config

* Restructure tests + fix normalization test

* Revert file

* add v1 to tox

* Skip testing ai_vad

* Increase train and test size

* use mvtec dataset

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Restructure test directories. (#1438)

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Replace black with ruff formatter (#1439)

* [Custom Trainer] Refactor export (#1440)

* Refactor export

* Fix entrypoint tests

* remove match statements

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add ruff checks to tests (#1455)

* Fix tests + add ruff check to tests

* Limit gradio version

* Path->str

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add dummy image dataset generator helper class (#1444)

* Created tests/v1 directory

* update license year

* Add beantech generator

* Refactor mvtec-ad and beantech

* Add visa dataset generator

* Add DummyImageGenerator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec3d dataset generator

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Add kolektor dataset

* add ucsdped generator

* Fix tests

* Revert conftest.py

* add method for generating avenue dataset

* Revert conftest.py

* add method for generating shanghaitech dataset

* swap order of typing for better parsing of normalization type

* cleanup

* Dynamically create DataFormat enum

* Add examples to docstring

* address pr comments and rename dataset.py to data.py

* Fix pre-commit issues

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>

* Remove configurable parameters (#1453)

* Refactor export

* Fix entrypoint tests

* remove match statements

* Fix tests + remove get_configurable_params + fix hpo,benchmarking

* Path->str

* Update src/anomalib/models/__init__.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/utils/sweep/config.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update tools/inference/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update tools/inference/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* str->Path

* str->Path

* Fix model checkpoint path

* typing + path + test order

* Update src/anomalib/utils/sweep/config.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Mark tests as xfail

* Fix notebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [v1] - Tests: Add datamodule tests. (#1456)

* Created tests/v1 directory

* update license year

* Add beantech generator

* Refactor mvtec-ad and beantech

* Add visa dataset generator

* Add DummyImageGenerator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec3d dataset generator

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Add kolektor dataset

* add ucsdped generator

* Fix tests

* Revert conftest.py

* add method for generating avenue dataset

* Revert conftest.py

* add method for generating shanghaitech dataset

* swap order of typing for better parsing of normalization type

* cleanup

* create the data tests files

* Dynamically create DataFormat enum

* Add examples to docstring

* add conftest.py

* address pr comments and rename dataset.py to data.py

* add some changes

* Add test_datasets to the integration tests

* Change order

* Added datamodule tests

* Format ruff

* Address pre-commit issues

* Fix video tests

* Add the rest of the datamodule tests

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>

* [Custom Trainer] Add train subcommand (#1465)

Add train subcommand

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Refactor `Tensor` annotation to `torch.Tensor` (#1477)

* Modify Tensor to torch.Tensor

* list[Tensor] to list[torch.Tensor]

* TODO: Fix formatting issues

* torch_all to torch.all

* Remove redundant import

* Apply ruff format

* Fix the tests

* Refactor tests Part 1 (#1473)

* Refactor CLI tests

* Select a random model

* Fix test for all the models

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add API tests Part 2 (#1474)

* Partially migrate unit tests Part 3 (#1480)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Address PR comments

* Refactor ckpt_path fixture

* Update conftest.py

* Update __init__.py

* Update __init__.py

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Reorg Part I: Data (#1483)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Refactor import statements in test_visualizer.py

* Reorg Part II: Remove `pre_processor` and `post_processor` subpackages (#1485)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Remove pre-processor subpackage from anomalib

* Remove unused imports and update import paths

* Refactor import statements in test_visualizer.py

* Remove unused code and deprecate Denormalize and
ToNumpy classes

* Remove empty code cell

* Add a description why input image is read from path

* Fix bug in superimpose

* Migrate deploy tests Part 4 (#1481)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* trained_padim_path->ckpt_path

* Split normalization line

* Fix normalization class path

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Migrate model components unit tests Part 5 (#1482)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Add todo

* Fix TaskType import

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Reorg Part III: Move the main anomalib components from `anomalib.utils` to `anomalib` (#1487)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Remove pre-processor subpackage from anomalib

* Remove unused imports and update import paths

* Refactor import statements in test_visualizer.py

* Move callbacks from utils under anomalib

* Fix import statements in benchmarking and CLI
modules

* Move CLI under anomalib

* Add benchmark to pipelines

* Move hpo to pipelines

* Move sweep to pipelines

* Move loggers to anomalib

* Move metrics to anomalib

* Move callbacks from utils to test/utils

* Move config to anomalib.utils

* Fix the metric imports

* Remove unused code and deprecate Denormalize and
ToNumpy classes

* Remove empty code cell

* Add a description why input image is read from path

* Fix bug in superimpose

* Move anomalib.utils.config.config to anomalib.utils.config

* Fix config import

* Merge feature/custom_trainer

* Migrate tools test Part 6 (#1488)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Migrate metrics tests

* Migrate tools + remove nightly

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* 🚜 Refactor padim and patchcore models (#1300)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* add is_fitted

* self.model._is_fitted to self.model.is_fitted

* Format anomaly module

* Remove on_save_checkpoint

* Refactor padim

* Add __repr__ to anomaly score threshold

* Revert patchcore config

* Add memory bank modules for anomaly detection

* Add explanation to MemoryBankTorchModule docstring.

* Update memory bank module imports and fix typo in
Padim model

* Rename Dynamic Buffer Module to Memory Bank
Module in docstring.

* Revert "Add explanation to MemoryBankTorchModule docstring."

This reverts commit 44c991450f7c78eee2b0ceb0e7c855c3893a0801.

* Refactor memory bank modules based on Dick's suggestion

* Fix model attribute assignment in lightning models

* Add MemoryBankMixin to anomaly detection models

* revert padim and patchcore

* Reorder inheritance in anomaly detection models

---------

Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>

* Migrate unit tests Part 7 (#1490)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Migrate metrics tests

* Migrate tools + remove nightly

* Increase coverage

* Migrate remaining tests

* Fix imports

* Fix import

* Update tests/unit/deploy/test_inferencer.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update test_get_logger.py

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Fix circular import in cdf normalizer (#1494)

* fix circular import in cdf normalizer

* fix pre-commit

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🛠️ Refactor: Split models to image and video (#1493)

* Move AiVad to anomalib.video

* Move cfa to models.image

* Add Ganomaly model to image models

* Add Fastflow model to image models

* Add EfficientAd anomaly detection model to image
models

* Move dfm, dfkde and draem

* Add CS-Flow model implementation for image-based
defect detection

* Add cflow to image models

* Add padim to image models

* Add patchcore to image models

* Add Reverse distillation to image models.

* Add rkde to image models

* Add stfpm to image models.

* Add image models for handling image datasets in
anomalib

* Update copyright year in model files

* Update import statement for Fastflow model

* Update image and video model documentation

* Update src/anomalib/models/video/README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update clip_length_in_frames parameter in
AvenueDataset and Avenue classes

* Remove folder references

* Fix a typo in readme

* Fix shape of image in batch

* Update clip_length_in_frames parameter

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* v1: Update the readme file (#1503)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Replace docs

* Add each inferencing scripts as a details section

* update readme

* Add training

* modify getting started

* Make getting started a subsection

* tmp

* Added inference section

* Refactor Lightning inference code

* Update entry point in setup.py

* Add training api example to readme

* Update training command in README

* Fix bug in login functionality

* Update HPO and Logging Documentation

* refactor getting started section

* Update HPO and benchmarking commands

* Update the image

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Remove getting started section

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Address the reviewer comments

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Extend Engine Tests (#1509)

* Add validate + predict

* Add train

* Add export tests + refactor export cli command

* Fix tests

* Fix jupyternotebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* v1: Create the new documentation via `sphinx-design` and `myst` (#1518)

* removed docs

* Created the new docs

* Finished get started

* Remove jupyter notebook from docs

* Add mvtec to data

* Add reference guide

* Add section for each image datasets

* Add base data modules and datasets

* v1 - 📝 Update and Enhance Docstrings (#1532)

* removed docs

* Created the new docs

* Finished get started

* Remove jupyter notebook from docs

* Add mvtec to data

* Add reference guide

* initial commit

* Remove subrocess from btech

* Remove unused import and commented out code

* Add section for each image datasets

* Add base data modules and datasets

* Refactor dataset classes and add docstrings

* Add initial draft for backbone docs

* Update the docstring in folder_3d

* Update mvtec 3d docstring

* Added feature extractor tutorial

* Add a readme file to the docs

* Update folder data docstring

* Update kolektor docstrings

* Update kolektor docstring

* Update mvtec docstring

* Update visa docstrings

* Update avenue docstring

* Update cfa docstring

* Update cflow docstring

* Update csflow docstring

* Update csflow docstring

* Update dfkde docstrings

* Update dfm docstring

* Update draem docstring

* Update efficient ad docstring

* Update ganomaly docstring

* Update padim and patchcore docstrings

* Update reverse distillation docstring

* update rkde docstring

* update stfpm docstring

* Update ai-vad docstring

* Update feature extractors

* add docstring to sparse random projection

* Update dimensionality reduction components

* Exclude prompt from copying

* Normalizing flow update

* Add pro

* Add feature extractor docs

* update aupr

* Update aupr

* Update aupro

* Update auroc

* Update docs/source/markdown/guides/how_to/models/feature_extractors.md

* Update f1 and manual thresholds

* add minmax

* add optimal f1

* update utils

* update comet

* add tensorboard

* update wandb

* Add callbacks

* Update deploy docstrings

* Fix pre-commit on Blasz changes

* Change the requirement file in readthedocs config file

* Partially address pr comments

* Fix the model to padim for the cli integration tests

---------

Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Blaz Rolih <blaz.rolih@gmail.com>

* Fix AI-VAD issues (#1524)

* partially fix empty bbox issue

* allow empty region detections

* add torch implementation of gmm (WIP)

* make knn mem bank persistent

* set val_split_mode to same_as_test as default to enforce deterministicness

* add unit tests and docstrings to gmm

* improve typing of knn estimator

* remove todo

* update buffer name

* fix minor mistakes in gmm implementation

* remove unnecessary tensor conversion

* fix visualization when predicting with video model

* add __init__.py to components.cluster

* check for empty bboxes in feature extractor

* reduce default batch size

* cast deep features to float

* fix device issue

* add unit tests for feature extractors

* add license header

* disable random model selection in integration tests

* typing and docstrings

* add test case for non-convergence warning

* 📝  v1 - Docs: Create a dedicated section for each model. (#1540)

* Initial commit for model components

* FIx the grid in model components

* Add image models

* Add video models

* Fix titles and do some cleanup

* reduce the sphinx version as it fails the readthedocs builds

* Fix examples for reading transforms from albumentations Compose object and deserializing from a yaml file

* Update __init__.py

* OpenVINO NNCF updates (#1534)

* Update versions of openvino and nncf

* All export functions return the model path

* Change default OV device to AUTO

* Minor changes on openvino API

* Fix pre-commit issues

* Restored onnx dependency

* Added OV export tests

* Drop export tests

* Rename path var

* Renamed test paths

* [Docs] Add average score to the FastFlow's performance results tables (#1587)

Add average score in the tables of performance results

* Update the paper title in CS-FLOW and CFLOW readme (#1579)

* Fix csflow name in readme

* Update cflow name in readme

* v1 - [Refactor] Reflect the changes in #1562 into v1 (#1595)

Reflect the changes in #1562 into v1

* ✏️ Refactor `ExportMode` to `ExportType` (#1594)

* Update export_mode to export_type

* Fix typo typel -> model

* Revert the python version in the notebook

* 📚 v1 - Modify the PR template (#1596)

* Modify the PR template

* Update pull_request_template.md

* added emojis to the checklist

* [Bug] v1: Fix default input normalization method (#1583)

Fix default input normalization method

* Modify `Engine.predict` (#1514)

* Add validate + predict

* Add train

* Add export tests + refactor export cli command

* Fix tests

* Fix jupyternotebook

* Update engine.predict + expand tests

* Fix lightning entrypoint test

* Address PR comments

* Use only Padim

* Fix commands

* Move padim to common args

* Address 1st PR comment

* Address PR comments

* Fix aivad tests

* Fix missing docstring

* Rename config to args

* Add missing ckpt_path warning in predict

* Remove ckpt_path as required parameter

* Add tests for image path in predict

* Fix image path in predict

* Address PR comments

* Fix missing checkpoint path

* Fix fastflow precommit issue

* Fix tests

* Fix test

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Fix issue with incorrect image save location (#1515)

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Upgrade gradio version to 4.x (#1608)

* upgrade gradio version to 4.x

* refactor variable names

* refactor

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* ✍ InferenceDataset->PredictDataset (#1544)

* ✍ InferenceDataset->PredictDataset

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update notebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* `FeatureExtractor` -> `TimmFeatureExtractor` (#1543)

Deprecate FeatureExtractor

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add `LearningType` and refactor enums (#1598)

* add LearningType and move enums to separate module

* add enum definitions

* move shared enums to root init

* place version above enums

* 📘 Add custom data tutorial (#1571)

* Add custom data tutorial

* Add the custom data training instructions

* Address PR comments

* Start with a classification data

* Release hazelnut toy dataset and refer to the link here.

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Remove no-val-test section from tutorials

* Address PR comments

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Samet Akcay <sakcay@Samets-MacBook-Pro.local>

* Add URL verification for downloading dataset (#1620)

* add url path verification for dataset downloading module

* specify node version to pre-commit-config

* fix import errors on the notebooks

* 🐞 v1 - Fix training with mps accelerator (#1618)

* Convert mask to float32 in AnomalibDataset

* Convert the tensor to cpu before convrting to numpy

* replace np.float32 with np.single

* Update Engine docstrings (#1549)

Update docstrings

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Fixed shape error, allowing arbitary image sizes for EfficientAD

* Revert the previous commit

* Extend supported models in TimmFeatureExtractor (#1443)

Extend Timm feature extractor for v1.0

* 🔒 v1 - Address security issues (#1637)

* Address path traversal issues 1-3

* address traversal path 6

* Address traverse path 8

* modify the comment to make it more descriptive

* 🐞 Fix mps float64 tensor conversion issue (#1644)

Fix leftover

* 🐞 Fix metadata_path arg to metadata in OpenVINO inferencer (#1648)

Fix metadata_path arg to metadata in OpenVINO inferencer

* 🔒 Address path traversal issues (#1643)

* Address path traversal issues 1-3

* address traversal path 6

* Address traverse path 8

* modify the comment to make it more descriptive

* Update get_image_filename function to enhance the input security

* fix example

* Fix incorrect default value assignment

* Refactor project_path fixture to create temporary directory in the root directory of the project

* Update .gitignore file to include test-related files and directories

* Refactor get_image_filenames_from_dir to filter out non-image files

* Add test case for path outside base directory

* Add examples to get_filenames

* Address PR comments.

* Renamed the tmp dir

* 🔒 Add `SECURITY.md` file (#1655)

* Add SECURITY.md file

* Add security item to the type of changes in the pull request template.

* Update pr template

* replace the security emoji

* 🚀 Add zero-/few-shot model support and WinCLIP model implementation (#1575)

* add clip normalization

* initial commit for winclip

* add cosine similarity computation

* add multiscale score computation

* simplify mask generation

* add few-shot extension (unvalidated)

* refactor

* cleanup

* add todo

* formatting

* minor refactor

* add comment

* expose optimal F1 metric

* some cleanup

* add ln_after_pool logic

* remove final_ln_after_pool

* update module docstring and remove comments

* add typing and docstrings to torch model

* cleanup lightning model

* hardcode backbone

* n_shot -> k_shot

* add temperature as constant

* minor bugfix

* add typing and docstrings to utils

* set class name dynamically

* replace inf values in harmonic aggregation

* run validate before test

* set default class name to None

* formatting

* remove config

* comments

* minor bugfix

* Revert "expose optimal F1 metric"

This reverts commit e8e1ead9601d76c743af3678f26b1eb0e06d38fb.

* more descriptive assert message

* expose scales as configurable parameter and hardcode pretrained as constant

* add readme

* add images for readme

* update docstrings

* update license headers

* ruff

* add openclip as requirement

* skip model tests for winclip

* fix visualizer test

* add example in docstring

* fix typo in function name

* typing

* imports

* docstrings

* check if model has trainer attribute

* remove pylint ignore statement

* typing

* docstring

* improve tensor shape handling

* refactor and rename class_scores function

* add docstring example

* commenting

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* formatting

* docstrings

* docstrings

* comment

* typing

* multiscale -> multi_scale

* add winclip to docs

* add few_shot_source parameter

* use PredictDataset in WinCLIP implementation

* add learning type to winclip lightning model

* add custom model checkpoint callback to save at validation end

* remove trainer arguments from winclip model

* prune state dict for smaller model file

* add learning type logic to engine.train

* pass full path to model checkpoint

* remove training step

* enable integration tests for winclip

* fix typo

* index masks at 0

* formatting

* simplify make_masks

* validate inputs in make_masks

* add unit tests for winclip utils

* add default class_name to prompt ensemble

* add unit tests for winclip prompt ensemble

* add base class for normalization callback

* add _should_run_validation check

* add engine.model property

* use custom modelcheckpoint in tests

* update name in todos

* fix predict tests

* skip export tests for winclip

* fix mistake in model retrieval from trainer

* add model checks

* fix checks

* simplify model check

* add todo for winclip export

* add todo

* add bufferlist mixin

* update bufferlist docstring

* add setup method and register buffers

* import torch model in root of winclip module

* add unit tests for bufferlist mixin

* add unit tests for torch model

* fix transform and update docstring

* disable strict loading in export

* initialize embeddings as tensors

* add test to check if erors are raised

* add todo

* enable winclip export test

* remove device references in torch model

* restore frozen weights in load_state_dict

* make embedding collection methods private

* move state dict handling to winclip from base

* fix typo

* make generate_masks private

* increase onnx opset version

* remove future import

* update docstring

* Update src/anomalib/callbacks/normalization/__init__.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/callbacks/normalization/cdf_normalization.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/callbacks/normalization/min_max_normalization.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* typing in docstrings

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* use exception instead of assert

* update license header

* docstrings

* bufferlist -> buffer_list

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* WinCLIP attribution (#1662)

give credit to related works

* 🔀 Merge main to v1 (#1652)

* Address tiler issues (#1411)

* fix tiler

* deprecate random tile locations

* restore random tiling in tile method

* check tiling section in config

* disable tiling for ganomalu

* pad -> padding

* Refactor Reverse Distillation to match official code (#1389)

* Non-mandatory early stopping

* Added conv4 and bn4 to OCBE

* Loss as in the official code (flattened arrays)

* Added comment on how to use torchvision model as an encoder to reproduce results in the paper

* Remove early stop from config, change default anomaly_map_mode to add

* pre-commit fix

* Updated results

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Remove early_stopping

* Update src/anomalib/models/reverse_distillation/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Easier to read code

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Patch for the WinError183 on the OpenVino export mode (#1386)

* Fix WinError183 (Windows Error)

* Add commentary of the change

---------

Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>

* Add DSR model (#1142)

* added license, init.py and draft readme

* added draft DSR files

* minor comment update

* Implemented dsr model + comments

* added dsr discrete model

* added defect generation in torch model + dsr to list of existing methods in init.py

* fixed torch model, started implementing lightning model, implemented anomaly generator

* added loss file for DSR

* Added loss, improved lightning module

* Finished up global implementation of DSR second phase

* minor fixes

* Bugfixes

* Fixed DSR loss calculation

* on_training_start -> on_train_start

* pre-commit run

* updated DSR documentation

* reset config file

* added automatic pretraining weight download

* testing pretrained weights. fixed embedding size in upsampling module and image recon module, to be fixed in original branch

* successful testing on pretrained dsr weights

* checked test quality with pretrained weights, fixed anomaly score calculation

* training is functional

* Fixed training procedure

* test still working

* working upsampling module training and testing

* fixed minor bugs

* updated documentation

* added tests and doc

* adapted learning schedule to steps

* Update src/anomalib/models/dsr/anomaly_generator.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactored outputs into dicts

* remove super() args

* changed downloading weights from anomalib releases + minor fixes

* pre commit hooks + minor fixes

* removed configurable ckpt path refs + default iteration nb from paper

* cleaned up dsr.rst and turned exceptions into RuntimeErrors

* Added upsampling ratio parameter to set third training phase epochs

* Added batched evalaution + minor code simplification

* pre commit hooks

* squeeze output image score tensor

* readded new path check in efficient ad

* fixed double step count with manual optimization

* fixed trailing whitespace

* Fix black issues

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* review suggestions

* updated architecture image links

* Address mypy

* changed output types for dsr model

* readded dict outputs, adapted to TorchInferencer

* fixed error in output dict

* removed default imagenet norm

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fix unexpected key pixel_metrics.AUPRO.fpr_limit (#1055)

* fix unexpected key pixel_metrics.AUPRO.fpr_limit

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* load AUPRO before create_metric_collection

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* code refine

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix comment

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* Support test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Improved speed and memory usage of mean+std calculation (#1457)

* preexisting OpenCV version check added to `setup.py`, ran formatting pre-commit hooks on previous contribution. (#1424)

* testing upstream switch

* picked up on stale OpenCV `setup.py` issue #1041

* 🐞 Hotfix: Limit Gradio Version (#1458)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Fix/efficient ad normalize before every validation (#1441)

* Normalize anomaly maps before every validation

* Remove print statement

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Fix DRAEM (#1431)

* Fix beta in augmenter

* Add scheduler

* Change normalization to none

* Replace two lr schedulers with MultiStepLR

* Revert change to beta

* Disable early stopping default

* Format config

* Add opacity parameter beta to config

* Adding U-Flow method (#1415)

* Added uflow model

* Added documentation (README) for uflow model

* Added uflow to the list of available models, and main README updated

* Added missing images for the documentation

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/feature_extraction.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Added uflow to the reference guide in docs

* Added uflow to the pre-merge tests

* removed the _step function, and merged the code with training_step

* added as a comment the values used in the paper

* re-factorized feature extractors to use the TimmFeatureExtractor class

* added annotations for some functions, where the flow graph is created

* updated readme to fix images loading

* Added link in the README to the original code for reproducing the results

* Removed unused kwargs

* Added docstrigs with args explanations to UFlow classes

* Added models in a github release, and linked here

* Passing all pre-commit checks

* Changed freia's AllInOneBlock by Anomalib's version, and converted the subnet contructor to a Class, in order to be pickable, that is needed to export the model to torch

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update README.md

* 📘 Announce anomalib v1 on the main `README.md` (#1542)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Announce anomalib v1 on readme

* Add the installation instructions and update the documentation link

* Fixed DSR (#1486)

* fixed DSR squeeze bug

* added comment

* Refactor/extensions custom dataset (#1562)

* Explanation how to use extension names in the config file

* Added information about extensions to the error message and control of the user input

* Easier to read code

* Replacing assert with raise

* 📚 Modify the PR template (#1611)

Update pull_request_template.md

* Fix result image URLs (#1510)

* Fix tests

* refactor path + fix issues + fix linting issues

* Migrate docs

* fix typing

* fix failing model tests

* Fix tests

* Address PR comments

* Fixed shape error, allowing arbitary image sizes for EfficientAD (#1537)

* Fixed shape error, allowing arbitrary image sizes. Replaced integer parsing by floor operation

* Replaced calculation by ceil operation. Solution of shape error is to round up and not down for the last upsample layer

* Add comment for ceil oepration

* Formatting with pre-commit hook

* Clean up badge

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: ggiret-thinkdeep <146845847+ggiret-thinkdeep@users.noreply.github.com>
Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>
Co-authored-by: Philippe Carvalho <31983398+phcarval@users.noreply.github.com>
Co-authored-by: Wenjing Kang <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: belfner <belfner@belfner.com>
Co-authored-by: Abdulla Al Blooshi <76493346+abdullamatar@users.noreply.github.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Matías Tailanian <895687+mtailanian@users.noreply.github.com>
Co-authored-by: Jan Schlüter <github@jan-schlueter.de>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Christopher <48522299+holzweber@users.noreply.github.com>

* Update license headers

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Samet <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Harim Kang <harim.kang@intel.com>
Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Blaz Rolih <blaz.rolih@gmail.com>
Co-authored-by: Adrian Boguszewski <adekboguszewski@gmail.com>
Co-authored-by: Willy Fitra Hendria <willyfitrahendria@gmail.com>
Co-authored-by: Samet Akcay <sakcay@Samets-MacBook-Pro.local>
Co-authored-by: Yunchu Lee <yunchu.lee@intel.com>
Co-authored-by: ggiret-thinkdeep <146845847+ggiret-thinkdeep@users.noreply.github.com>
Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>
Co-authored-by: Philippe Carvalho <31983398+phcarval@users.noreply.github.com>
Co-authored-by: Wenjing Kang <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: belfner <belfner@belfner.com>
Co-authored-by: Abdulla Al Blooshi <76493346+abdullamatar@users.noreply.github.com>
Co-authored-by: Matías Tailanian <895687+mtailanian@users.noreply.github.com>
Co-authored-by: Jan Schlüter <github@jan-schlueter.de>
Co-authored-by: Christopher <48522299+holzweber@users.noreply.github.com>
samet-akcay added a commit that referenced this pull request Jan 25, 2024
* Merge feature/lightning-version-upgrade to feature/custom-trainer (#1297)

Upgrade to Lightning 2.0.5 (#1221)

* Adapt code and configs to PL 2.0.5

* Pre-commit checks.

* Fix a function call.

* Fix function calls.

* pytorch_lightning -> lightning.pytorch

* Add lightning to requirements

---------

Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Samet <samet.akcay@intel.com>

* Partially restore tests (#1298)

* Upgrade to Lightning 2.0.5 (#1221)

* Adapt code and configs to PL 2.0.5

* Pre-commit checks.

* Fix a function call.

* Fix function calls.

* pytorch_lightning -> lightning.pytorch

* Add lightning to requirements

---------

Co-authored-by: Samet <samet.akcay@intel.com>

* partially restore tests

* Address PR comments

---------

Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Samet <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Remove future annotations (#1299)

* remove __future__

* Update changelog

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Refactor postprocessing (#1302)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Remove handler

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] refactor normalization callbacks (#1310)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

---------

* [Custom Trainer] Refactor thresholding (#1311)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [Custom Trainer] Refactor Metrics (#1312)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Refactor metrics configuration

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Refactor visualization callback (#1313)

* remove __future__

* Update changelog

* 🚚 Trainer -> AnomalibTrainer

* add post-processor

* Refactor callback

* Refactor normalization callback

* Refactor thresholding

* Refactor metrics configuration

* Move visualizer callbacks into trainer

* Match convention

* Refactor imports

* Address PR comments

* Fix path

* Refactor callbacks

* Fix module path

* Address PR comments

* Remove comment

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Initial engine design (#1348)

* Initial engine design

* Address PR comments

* Circular import + trainer->engine

* Update src/anomalib/engine/engine.py

* revert import in __init__

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [Custom Trainer] Partially fix tests (#1359)

* Partially fix test

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Add CLI support (#1381)

* Support trainer methods

* support yaml serialization

* add hpo command

* Add benchmark + train entrypoint

* Add export arguments

* Partially address PR comments

* Add export subcommands + refactor

* Address PR comments

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Partially restore tests (#1391)

* Fix tests

* Patch get experiment logger

* Sort imports

* Add stfpm config

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add new ruff rules (#1390)

* Add rules to pyproject.toml file

* Only include padim and stfpm in tests

* Fix notebook tests

* Fix notebook tests

* Code quality/enable rules (#1394)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* Enable Ruff rules - Part III (#1397)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* Enable Ruff Rules - Part 4 (#1402)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* [Custom Trainer] Switch to manual optimization for ganomaly (#1404)

* implement manual optimizers for ganomaly

* cleanup

* Enable Ruff Rules - Part 5 (#1403)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* Update src/anomalib/models/components/flow/all_in_one_block.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* addressed pr comments

---------

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* [Custom Trainer] Add import checks (#1393)

* Add checks

* Add checks for wandb

* move exception handling to method

* fix pre-commit issue

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Remove max epochs > 1 (#1400)

Remove max epochs>1 from default param list

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* [Custom Trainer] Add default values (#1395)

* Add checks

* Add default values to datasets + padim model

* update default values

* Remove merge artifact

* Change gt path

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Enable Ruff Rules - Part 6 (#1407)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* Enable Ruff Rules - Part 7 (#1408)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* Fix random_split tests

* Fix pre-commit

* Fixed the logger test

* Fix the typos in todos

* Enable Ruff Rules - Part 8 (#1412)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Enable Ruff Rules - Part 9 (#1419)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Update src/anomalib/utils/metrics/binning.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update src/anomalib/models/dfkde/lightning_model.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update src/anomalib/models/rkde/feature_extractor.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fixed pre-commit

---------

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Merge main into feature/custom_trainer (#1420)

* Address tiler issues (#1411)

* fix tiler

* deprecate random tile locations

* restore random tiling in tile method

* check tiling section in config

* disable tiling for ganomalu

* pad -> padding

* Refactor Reverse Distillation to match official code (#1389)

* Non-mandatory early stopping

* Added conv4 and bn4 to OCBE

* Loss as in the official code (flattened arrays)

* Added comment on how to use torchvision model as an encoder to reproduce results in the paper

* Remove early stop from config, change default anomaly_map_mode to add

* pre-commit fix

* Updated results

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Remove early_stopping

* Update src/anomalib/models/reverse_distillation/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Easier to read code

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Enable Ruff Rules - Part 10 (#1423)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Enabled "PLW2901",  # `for` loop variable `row` overwritten by assignment target

* Enable Ruff Rules - Part 11 (#1425)

* pyflakes

* pycodestyle

* pep8-naming (`N`)

* pyupgrade (`UP`)

* flake8-bandit (`S`)

* Enabled UP, ANN, S, BLE, FBT, B

* Fix typo

* Revert F1AdaptiveThreshold parent classes

* Fix some of the tests

* ignore boolean-positional-value-in-call (FBT003)

* Addressed pr comments

* Remove duplicated lines

* flake8-builtins (`A`) and flake8-commas (`COM`)

* flake8-comprehensions (`C4`)

* flake8-datatimez (`DTZ`), flake8-debugger (`T10`), flake8-errmsg (`EM`)

* flake8-pie (`PIE`)

* flake8-raise (`RSE`)

* flake8-return (`RET`)

* flake8-self (`SLF`)

* flake8-simplify (`SIM`)

* flake8-unsused-arguments (`ARG`)

* flake8-use-pathlib (`PTH`)

* eradicate (`ERA`)

* pylint (`PL`)

* tryceratos (`TRY`), flynt (`FLY`), Perflint (`PERF`)

* NumPy-specific rules (`NPY`)

* Ruff-specific rules (`RUF`)

* Remove pylint ignore comments

* Fix tests

* Fix tests

* mccabe (`C90`)

* pygrep-hooks (`PGH`)

* flake8-todos (`TD`)

* flake8-fixme (`FIX`)

* pandas-vet (`PD`)

* ignore ANN101 ANN102 and ANN103

* Fix random_split tests

* Fix pre-commit

* ANN partly done

* Remove kwargs: Any

* flake8-annotations (`ANN`)

* Enabled tests

* Revert padim configs

* Add auto fixes

* Fix docstrings

* Enabled "PLW2901",  # `for` loop variable `row` overwritten by assignment target

* Add google style to pydocstyle

* Remove dashed line from Returns

* Remove dashed line from Args

* Remove dashed line from Example and Raises

* Removed left-over dashed lines

* Cleanup pyproject.toml file

* [Custom Trainer] Add a verbose help output structure to the CLI (#1396)

* Add Verbosity Help-Formatter class

* Add Help-Formatter unit-tests

* Fix some strings

* Fix pre-commit ruff stuff

* Fix help_formatter's pre-commit

* Add new configs (#1418)

* Add new configs

* Add draem config

* Fix docstring

* Update src/anomalib/models/cflow/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Linting

* Remove --- from docstrings

* Remove any from return type

* Fix linting issues from feature/custom_trainer

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Add CLI Tests (#1426)

* Add new configs

* Add draem config

* Stash cli tests

* Stash cli tests with minor changes

* Stash changes

* Fix reverse distillation

* Fix EfficientAD

* Match ai_vad params to config params

* Fix ucsd and ai_vad configs

* Uncomment validation step

* Refactor directory structure

* Rename method

* use uscd for aivad

* fix ucsd path + modify model checkpoint callback for tests

* fix dfkde config

* Restructure tests + fix normalization test

* Revert file

* add v1 to tox

* Skip testing ai_vad

* Increase train and test size

* use mvtec dataset

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Restructure test directories. (#1438)

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Replace black with ruff formatter (#1439)

* [Custom Trainer] Refactor export (#1440)

* Refactor export

* Fix entrypoint tests

* remove match statements

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add ruff checks to tests (#1455)

* Fix tests + add ruff check to tests

* Limit gradio version

* Path->str

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add dummy image dataset generator helper class (#1444)

* Created tests/v1 directory

* update license year

* Add beantech generator

* Refactor mvtec-ad and beantech

* Add visa dataset generator

* Add DummyImageGenerator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec3d dataset generator

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Add kolektor dataset

* add ucsdped generator

* Fix tests

* Revert conftest.py

* add method for generating avenue dataset

* Revert conftest.py

* add method for generating shanghaitech dataset

* swap order of typing for better parsing of normalization type

* cleanup

* Dynamically create DataFormat enum

* Add examples to docstring

* address pr comments and rename dataset.py to data.py

* Fix pre-commit issues

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>

* Remove configurable parameters (#1453)

* Refactor export

* Fix entrypoint tests

* remove match statements

* Fix tests + remove get_configurable_params + fix hpo,benchmarking

* Path->str

* Update src/anomalib/models/__init__.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/utils/sweep/config.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update tools/inference/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update tools/inference/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* str->Path

* str->Path

* Fix model checkpoint path

* typing + path + test order

* Update src/anomalib/utils/sweep/config.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Mark tests as xfail

* Fix notebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* [v1] - Tests: Add datamodule tests. (#1456)

* Created tests/v1 directory

* update license year

* Add beantech generator

* Refactor mvtec-ad and beantech

* Add visa dataset generator

* Add DummyImageGenerator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec dataset generator

* Use DummyImageGenerator in dummy mvtec3d dataset generator

* Restructured the test directories

* Fixed typo

* Fix imports

* Fix config path in export tests

* Add kolektor dataset

* add ucsdped generator

* Fix tests

* Revert conftest.py

* add method for generating avenue dataset

* Revert conftest.py

* add method for generating shanghaitech dataset

* swap order of typing for better parsing of normalization type

* cleanup

* create the data tests files

* Dynamically create DataFormat enum

* Add examples to docstring

* add conftest.py

* address pr comments and rename dataset.py to data.py

* add some changes

* Add test_datasets to the integration tests

* Change order

* Added datamodule tests

* Format ruff

* Address pre-commit issues

* Fix video tests

* Add the rest of the datamodule tests

---------

Co-authored-by: Dick Ameln <dick.ameln@intel.com>

* [Custom Trainer] Add train subcommand (#1465)

Add train subcommand

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Refactor `Tensor` annotation to `torch.Tensor` (#1477)

* Modify Tensor to torch.Tensor

* list[Tensor] to list[torch.Tensor]

* TODO: Fix formatting issues

* torch_all to torch.all

* Remove redundant import

* Apply ruff format

* Fix the tests

* Refactor tests Part 1 (#1473)

* Refactor CLI tests

* Select a random model

* Fix test for all the models

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add API tests Part 2 (#1474)

* Partially migrate unit tests Part 3 (#1480)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Address PR comments

* Refactor ckpt_path fixture

* Update conftest.py

* Update __init__.py

* Update __init__.py

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Reorg Part I: Data (#1483)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Refactor import statements in test_visualizer.py

* Reorg Part II: Remove `pre_processor` and `post_processor` subpackages (#1485)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Remove pre-processor subpackage from anomalib

* Remove unused imports and update import paths

* Refactor import statements in test_visualizer.py

* Remove unused code and deprecate Denormalize and
ToNumpy classes

* Remove empty code cell

* Add a description why input image is read from path

* Fix bug in superimpose

* Migrate deploy tests Part 4 (#1481)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* trained_padim_path->ckpt_path

* Split normalization line

* Fix normalization class path

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Migrate model components unit tests Part 5 (#1482)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Add todo

* Fix TaskType import

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Reorg Part III: Move the main anomalib components from `anomalib.utils` to `anomalib` (#1487)

* Update Anomalib data with the new structure

* Update dataset imports and remove unused imports

* ruff format in engine.py

* Move TaskType to utils/types

* Revert TaskType import from anomalib

* Revert tox.ini

* Refactor imports and fix import errors

* Fix import errors and update type annotations

* Fix imports in jupyter notebooks

* Remove pre-processor subpackage from anomalib

* Remove unused imports and update import paths

* Refactor import statements in test_visualizer.py

* Move callbacks from utils under anomalib

* Fix import statements in benchmarking and CLI
modules

* Move CLI under anomalib

* Add benchmark to pipelines

* Move hpo to pipelines

* Move sweep to pipelines

* Move loggers to anomalib

* Move metrics to anomalib

* Move callbacks from utils to test/utils

* Move config to anomalib.utils

* Fix the metric imports

* Remove unused code and deprecate Denormalize and
ToNumpy classes

* Remove empty code cell

* Add a description why input image is read from path

* Fix bug in superimpose

* Move anomalib.utils.config.config to anomalib.utils.config

* Fix config import

* Merge feature/custom_trainer

* Migrate tools test Part 6 (#1488)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Migrate metrics tests

* Migrate tools + remove nightly

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* 🚜 Refactor padim and patchcore models (#1300)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* add is_fitted

* self.model._is_fitted to self.model.is_fitted

* Format anomaly module

* Remove on_save_checkpoint

* Refactor padim

* Add __repr__ to anomaly score threshold

* Revert patchcore config

* Add memory bank modules for anomaly detection

* Add explanation to MemoryBankTorchModule docstring.

* Update memory bank module imports and fix typo in
Padim model

* Rename Dynamic Buffer Module to Memory Bank
Module in docstring.

* Revert "Add explanation to MemoryBankTorchModule docstring."

This reverts commit 44c991450f7c78eee2b0ceb0e7c855c3893a0801.

* Refactor memory bank modules based on Dick's suggestion

* Fix model attribute assignment in lightning models

* Add MemoryBankMixin to anomaly detection models

* revert padim and patchcore

* Reorder inheritance in anomaly detection models

---------

Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>

* Migrate unit tests Part 7 (#1490)

* Refactor CLI tests

* Add api tests

* Select a random model

* Fix test for all the models

* Fix API tests

* refactor pre-post processing + get model ckpt from fixture

* Add tests for custom transforms

* Migrate deploy tests

* Migrate model component tests

* Migrate visualizer callback + cli tests

* Fix lightning entrypoint test

* trained_padim_path->ckpt_path

* Migrate metrics tests

* Migrate tools + remove nightly

* Increase coverage

* Migrate remaining tests

* Fix imports

* Fix import

* Update tests/unit/deploy/test_inferencer.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update test_get_logger.py

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Fix circular import in cdf normalizer (#1494)

* fix circular import in cdf normalizer

* fix pre-commit

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🛠️ Refactor: Split models to image and video (#1493)

* Move AiVad to anomalib.video

* Move cfa to models.image

* Add Ganomaly model to image models

* Add Fastflow model to image models

* Add EfficientAd anomaly detection model to image
models

* Move dfm, dfkde and draem

* Add CS-Flow model implementation for image-based
defect detection

* Add cflow to image models

* Add padim to image models

* Add patchcore to image models

* Add Reverse distillation to image models.

* Add rkde to image models

* Add stfpm to image models.

* Add image models for handling image datasets in
anomalib

* Update copyright year in model files

* Update import statement for Fastflow model

* Update image and video model documentation

* Update src/anomalib/models/video/README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update clip_length_in_frames parameter in
AvenueDataset and Avenue classes

* Remove folder references

* Fix a typo in readme

* Fix shape of image in batch

* Update clip_length_in_frames parameter

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* v1: Update the readme file (#1503)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Replace docs

* Add each inferencing scripts as a details section

* update readme

* Add training

* modify getting started

* Make getting started a subsection

* tmp

* Added inference section

* Refactor Lightning inference code

* Update entry point in setup.py

* Add training api example to readme

* Update training command in README

* Fix bug in login functionality

* Update HPO and Logging Documentation

* refactor getting started section

* Update HPO and benchmarking commands

* Update the image

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Remove getting started section

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update README.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Address the reviewer comments

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Extend Engine Tests (#1509)

* Add validate + predict

* Add train

* Add export tests + refactor export cli command

* Fix tests

* Fix jupyternotebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* v1: Create the new documentation via `sphinx-design` and `myst` (#1518)

* removed docs

* Created the new docs

* Finished get started

* Remove jupyter notebook from docs

* Add mvtec to data

* Add reference guide

* Add section for each image datasets

* Add base data modules and datasets

* v1 - 📝 Update and Enhance Docstrings (#1532)

* removed docs

* Created the new docs

* Finished get started

* Remove jupyter notebook from docs

* Add mvtec to data

* Add reference guide

* initial commit

* Remove subrocess from btech

* Remove unused import and commented out code

* Add section for each image datasets

* Add base data modules and datasets

* Refactor dataset classes and add docstrings

* Add initial draft for backbone docs

* Update the docstring in folder_3d

* Update mvtec 3d docstring

* Added feature extractor tutorial

* Add a readme file to the docs

* Update folder data docstring

* Update kolektor docstrings

* Update kolektor docstring

* Update mvtec docstring

* Update visa docstrings

* Update avenue docstring

* Update cfa docstring

* Update cflow docstring

* Update csflow docstring

* Update csflow docstring

* Update dfkde docstrings

* Update dfm docstring

* Update draem docstring

* Update efficient ad docstring

* Update ganomaly docstring

* Update padim and patchcore docstrings

* Update reverse distillation docstring

* update rkde docstring

* update stfpm docstring

* Update ai-vad docstring

* Update feature extractors

* add docstring to sparse random projection

* Update dimensionality reduction components

* Exclude prompt from copying

* Normalizing flow update

* Add pro

* Add feature extractor docs

* update aupr

* Update aupr

* Update aupro

* Update auroc

* Update docs/source/markdown/guides/how_to/models/feature_extractors.md

* Update f1 and manual thresholds

* add minmax

* add optimal f1

* update utils

* update comet

* add tensorboard

* update wandb

* Add callbacks

* Update deploy docstrings

* Fix pre-commit on Blasz changes

* Change the requirement file in readthedocs config file

* Partially address pr comments

* Fix the model to padim for the cli integration tests

---------

Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Blaz Rolih <blaz.rolih@gmail.com>

* Fix AI-VAD issues (#1524)

* partially fix empty bbox issue

* allow empty region detections

* add torch implementation of gmm (WIP)

* make knn mem bank persistent

* set val_split_mode to same_as_test as default to enforce deterministicness

* add unit tests and docstrings to gmm

* improve typing of knn estimator

* remove todo

* update buffer name

* fix minor mistakes in gmm implementation

* remove unnecessary tensor conversion

* fix visualization when predicting with video model

* add __init__.py to components.cluster

* check for empty bboxes in feature extractor

* reduce default batch size

* cast deep features to float

* fix device issue

* add unit tests for feature extractors

* add license header

* disable random model selection in integration tests

* typing and docstrings

* add test case for non-convergence warning

* 📝  v1 - Docs: Create a dedicated section for each model. (#1540)

* Initial commit for model components

* FIx the grid in model components

* Add image models

* Add video models

* Fix titles and do some cleanup

* reduce the sphinx version as it fails the readthedocs builds

* Fix examples for reading transforms from albumentations Compose object and deserializing from a yaml file

* Update __init__.py

* OpenVINO NNCF updates (#1534)

* Update versions of openvino and nncf

* All export functions return the model path

* Change default OV device to AUTO

* Minor changes on openvino API

* Fix pre-commit issues

* Restored onnx dependency

* Added OV export tests

* Drop export tests

* Rename path var

* Renamed test paths

* [Docs] Add average score to the FastFlow's performance results tables (#1587)

Add average score in the tables of performance results

* Update the paper title in CS-FLOW and CFLOW readme (#1579)

* Fix csflow name in readme

* Update cflow name in readme

* v1 - [Refactor] Reflect the changes in #1562 into v1 (#1595)

Reflect the changes in #1562 into v1

* ✏️ Refactor `ExportMode` to `ExportType` (#1594)

* Update export_mode to export_type

* Fix typo typel -> model

* Revert the python version in the notebook

* 📚 v1 - Modify the PR template (#1596)

* Modify the PR template

* Update pull_request_template.md

* added emojis to the checklist

* [Bug] v1: Fix default input normalization method (#1583)

Fix default input normalization method

* Modify `Engine.predict` (#1514)

* Add validate + predict

* Add train

* Add export tests + refactor export cli command

* Fix tests

* Fix jupyternotebook

* Update engine.predict + expand tests

* Fix lightning entrypoint test

* Address PR comments

* Use only Padim

* Fix commands

* Move padim to common args

* Address 1st PR comment

* Address PR comments

* Fix aivad tests

* Fix missing docstring

* Rename config to args

* Add missing ckpt_path warning in predict

* Remove ckpt_path as required parameter

* Add tests for image path in predict

* Fix image path in predict

* Address PR comments

* Fix missing checkpoint path

* Fix fastflow precommit issue

* Fix tests

* Fix test

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Fix issue with incorrect image save location (#1515)

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Upgrade gradio version to 4.x (#1608)

* upgrade gradio version to 4.x

* refactor variable names

* refactor

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* ✍ InferenceDataset->PredictDataset (#1544)

* ✍ InferenceDataset->PredictDataset

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update predict dataset references

* update notebook

---------

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* `FeatureExtractor` -> `TimmFeatureExtractor` (#1543)

Deprecate FeatureExtractor

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Add `LearningType` and refactor enums (#1598)

* add LearningType and move enums to separate module

* add enum definitions

* move shared enums to root init

* place version above enums

* 📘 Add custom data tutorial (#1571)

* Add custom data tutorial

* Add the custom data training instructions

* Address PR comments

* Start with a classification data

* Release hazelnut toy dataset and refer to the link here.

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Update docs/source/markdown/guides/how_to/data/custom_data.md

Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Remove no-val-test section from tutorials

* Address PR comments

---------

Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Samet Akcay <sakcay@Samets-MacBook-Pro.local>

* Add URL verification for downloading dataset (#1620)

* add url path verification for dataset downloading module

* specify node version to pre-commit-config

* fix import errors on the notebooks

* 🐞 v1 - Fix training with mps accelerator (#1618)

* Convert mask to float32 in AnomalibDataset

* Convert the tensor to cpu before convrting to numpy

* replace np.float32 with np.single

* Update Engine docstrings (#1549)

Update docstrings

Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>

* Fixed shape error, allowing arbitary image sizes for EfficientAD

* Revert the previous commit

* Extend supported models in TimmFeatureExtractor (#1443)

Extend Timm feature extractor for v1.0

* 🔒 v1 - Address security issues (#1637)

* Address path traversal issues 1-3

* address traversal path 6

* Address traverse path 8

* modify the comment to make it more descriptive

* 🐞 Fix mps float64 tensor conversion issue (#1644)

Fix leftover

* 🐞 Fix metadata_path arg to metadata in OpenVINO inferencer (#1648)

Fix metadata_path arg to metadata in OpenVINO inferencer

* 🔒 Address path traversal issues (#1643)

* Address path traversal issues 1-3

* address traversal path 6

* Address traverse path 8

* modify the comment to make it more descriptive

* Update get_image_filename function to enhance the input security

* fix example

* Fix incorrect default value assignment

* Refactor project_path fixture to create temporary directory in the root directory of the project

* Update .gitignore file to include test-related files and directories

* Refactor get_image_filenames_from_dir to filter out non-image files

* Add test case for path outside base directory

* Add examples to get_filenames

* Address PR comments.

* Renamed the tmp dir

* CVS-129503

* add validate_path to anomalib.data.utils.path

* Validate depth path

* 🔒 Add `SECURITY.md` file (#1655)

* Add SECURITY.md file

* Add security item to the type of changes in the pull request template.

* Update pr template

* replace the security emoji

* Validate path in make_dataset functions

* Add a check whether path contains null byte

* fix tests

* Remove duplicated tests that causes the ci fail

* 🚀 Add zero-/few-shot model support and WinCLIP model implementation (#1575)

* add clip normalization

* initial commit for winclip

* add cosine similarity computation

* add multiscale score computation

* simplify mask generation

* add few-shot extension (unvalidated)

* refactor

* cleanup

* add todo

* formatting

* minor refactor

* add comment

* expose optimal F1 metric

* some cleanup

* add ln_after_pool logic

* remove final_ln_after_pool

* update module docstring and remove comments

* add typing and docstrings to torch model

* cleanup lightning model

* hardcode backbone

* n_shot -> k_shot

* add temperature as constant

* minor bugfix

* add typing and docstrings to utils

* set class name dynamically

* replace inf values in harmonic aggregation

* run validate before test

* set default class name to None

* formatting

* remove config

* comments

* minor bugfix

* Revert "expose optimal F1 metric"

This reverts commit e8e1ead9601d76c743af3678f26b1eb0e06d38fb.

* more descriptive assert message

* expose scales as configurable parameter and hardcode pretrained as constant

* add readme

* add images for readme

* update docstrings

* update license headers

* ruff

* add openclip as requirement

* skip model tests for winclip

* fix visualizer test

* add example in docstring

* fix typo in function name

* typing

* imports

* docstrings

* check if model has trainer attribute

* remove pylint ignore statement

* typing

* docstring

* improve tensor shape handling

* refactor and rename class_scores function

* add docstring example

* commenting

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/image/winclip/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* formatting

* docstrings

* docstrings

* comment

* typing

* multiscale -> multi_scale

* add winclip to docs

* add few_shot_source parameter

* use PredictDataset in WinCLIP implementation

* add learning type to winclip lightning model

* add custom model checkpoint callback to save at validation end

* remove trainer arguments from winclip model

* prune state dict for smaller model file

* add learning type logic to engine.train

* pass full path to model checkpoint

* remove training step

* enable integration tests for winclip

* fix typo

* index masks at 0

* formatting

* simplify make_masks

* validate inputs in make_masks

* add unit tests for winclip utils

* add default class_name to prompt ensemble

* add unit tests for winclip prompt ensemble

* add base class for normalization callback

* add _should_run_validation check

* add engine.model property

* use custom modelcheckpoint in tests

* update name in todos

* fix predict tests

* skip export tests for winclip

* fix mistake in model retrieval from trainer

* add model checks

* fix checks

* simplify model check

* add todo for winclip export

* add todo

* add bufferlist mixin

* update bufferlist docstring

* add setup method and register buffers

* import torch model in root of winclip module

* add unit tests for bufferlist mixin

* add unit tests for torch model

* fix transform and update docstring

* disable strict loading in export

* initialize embeddings as tensors

* add test to check if erors are raised

* add todo

* enable winclip export test

* remove device references in torch model

* restore frozen weights in load_state_dict

* make embedding collection methods private

* move state dict handling to winclip from base

* fix typo

* make generate_masks private

* increase onnx opset version

* remove future import

* update docstring

* Update src/anomalib/callbacks/normalization/__init__.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/callbacks/normalization/cdf_normalization.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/callbacks/normalization/min_max_normalization.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* typing in docstrings

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/engine/engine.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* use exception instead of assert

* update license header

* docstrings

* bufferlist -> buffer_list

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Check if the path too long and contains non-printable chars

* WinCLIP attribution (#1662)

give credit to related works

* 🔀 Merge main to v1 (#1652)

* Address tiler issues (#1411)

* fix tiler

* deprecate random tile locations

* restore random tiling in tile method

* check tiling section in config

* disable tiling for ganomalu

* pad -> padding

* Refactor Reverse Distillation to match official code (#1389)

* Non-mandatory early stopping

* Added conv4 and bn4 to OCBE

* Loss as in the official code (flattened arrays)

* Added comment on how to use torchvision model as an encoder to reproduce results in the paper

* Remove early stop from config, change default anomaly_map_mode to add

* pre-commit fix

* Updated results

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/reverse_distillation/README.md

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Remove early_stopping

* Update src/anomalib/models/reverse_distillation/lightning_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Easier to read code

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Patch for the WinError183 on the OpenVino export mode (#1386)

* Fix WinError183 (Windows Error)

* Add commentary of the change

---------

Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>

* Add DSR model (#1142)

* added license, init.py and draft readme

* added draft DSR files

* minor comment update

* Implemented dsr model + comments

* added dsr discrete model

* added defect generation in torch model + dsr to list of existing methods in init.py

* fixed torch model, started implementing lightning model, implemented anomaly generator

* added loss file for DSR

* Added loss, improved lightning module

* Finished up global implementation of DSR second phase

* minor fixes

* Bugfixes

* Fixed DSR loss calculation

* on_training_start -> on_train_start

* pre-commit run

* updated DSR documentation

* reset config file

* added automatic pretraining weight download

* testing pretrained weights. fixed embedding size in upsampling module and image recon module, to be fixed in original branch

* successful testing on pretrained dsr weights

* checked test quality with pretrained weights, fixed anomaly score calculation

* training is functional

* Fixed training procedure

* test still working

* working upsampling module training and testing

* fixed minor bugs

* updated documentation

* added tests and doc

* adapted learning schedule to steps

* Update src/anomalib/models/dsr/anomaly_generator.py

Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactored outputs into dicts

* remove super() args

* changed downloading weights from anomalib releases + minor fixes

* pre commit hooks + minor fixes

* removed configurable ckpt path refs + default iteration nb from paper

* cleaned up dsr.rst and turned exceptions into RuntimeErrors

* Added upsampling ratio parameter to set third training phase epochs

* Added batched evalaution + minor code simplification

* pre commit hooks

* squeeze output image score tensor

* readded new path check in efficient ad

* fixed double step count with manual optimization

* fixed trailing whitespace

* Fix black issues

* Apply suggestions from code review

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* review suggestions

* updated architecture image links

* Address mypy

* changed output types for dsr model

* readded dict outputs, adapted to TorchInferencer

* fixed error in output dict

* removed default imagenet norm

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fix unexpected key pixel_metrics.AUPRO.fpr_limit (#1055)

* fix unexpected key pixel_metrics.AUPRO.fpr_limit

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* load AUPRO before create_metric_collection

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* code refine

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix comment

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* fix

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>

* Support test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

* Update test

Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Improved speed and memory usage of mean+std calculation (#1457)

* preexisting OpenCV version check added to `setup.py`, ran formatting pre-commit hooks on previous contribution. (#1424)

* testing upstream switch

* picked up on stale OpenCV `setup.py` issue #1041

* 🐞 Hotfix: Limit Gradio Version (#1458)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Fix/efficient ad normalize before every validation (#1441)

* Normalize anomaly maps before every validation

* Remove print statement

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Fix DRAEM (#1431)

* Fix beta in augmenter

* Add scheduler

* Change normalization to none

* Replace two lr schedulers with MultiStepLR

* Revert change to beta

* Disable early stopping default

* Format config

* Add opacity parameter beta to config

* Adding U-Flow method (#1415)

* Added uflow model

* Added documentation (README) for uflow model

* Added uflow to the list of available models, and main README updated

* Added missing images for the documentation

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/anomaly_map.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/feature_extraction.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/models/uflow/torch_model.py

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Added uflow to the reference guide in docs

* Added uflow to the pre-merge tests

* removed the _step function, and merged the code with training_step

* added as a comment the values used in the paper

* re-factorized feature extractors to use the TimmFeatureExtractor class

* added annotations for some functions, where the flow graph is created

* updated readme to fix images loading

* Added link in the README to the original code for reproducing the results

* Removed unused kwargs

* Added docstrigs with args explanations to UFlow classes

* Added models in a github release, and linked here

* Passing all pre-commit checks

* Changed freia's AllInOneBlock by Anomalib's version, and converted the subnet contructor to a Class, in order to be pickable, that is needed to export the model to torch

---------

Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Update README.md

* 📘 Announce anomalib v1 on the main `README.md` (#1542)

* Fix metadata path

* Ignore hidden directories in folder dataset

* Add check for mask_dir for segmentation tasks in Folder dataset

* Limit the gradio version to <4

* Announce anomalib v1 on readme

* Add the installation instructions and update the documentation link

* Fixed DSR (#1486)

* fixed DSR squeeze bug

* added comment

* Refactor/extensions custom dataset (#1562)

* Explanation how to use extension names in the config file

* Added information about extensions to the error message and control of the user input

* Easier to read code

* Replacing assert with raise

* 📚 Modify the PR template (#1611)

Update pull_request_template.md

* Fix result image URLs (#1510)

* Fix tests

* refactor path + fix issues + fix linting issues

* Migrate docs

* fix typing

* fix failing model tests

* Fix tests

* Address PR comments

* Fixed shape error, allowing arbitary image sizes for EfficientAD (#1537)

* Fixed shape error, allowing arbitrary image sizes. Replaced integer parsing by floor operation

* Replaced calculation by ceil operation. Solution of shape error is to round up and not down for the last upsample layer

* Add comment for ceil oepration

* Formatting with pre-commit hook

* Clean up badge

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: ggiret-thinkdeep <146845847+ggiret-thinkdeep@users.noreply.github.com>
Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>
Co-authored-by: Philippe Carvalho <31983398+phcarval@users.noreply.github.com>
Co-authored-by: Wenjing Kang <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: belfner <belfner@belfner.com>
Co-authored-by: Abdulla Al Blooshi <76493346+abdullamatar@users.noreply.github.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Matías Tailanian <895687+mtailanian@users.noreply.github.com>
Co-authored-by: Jan Schlüter <github@jan-schlueter.de>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Christopher <48522299+holzweber@users.noreply.github.com>

* Update license headers

* Check symlinks

---------

Signed-off-by: FanJiangIntel <fan.jiang@intel.com>
Signed-off-by: Kang Wenjing <wenjing.kang@intel.com>
Signed-off-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Co-authored-by: Weilin Xu <mzweilin@gmail.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Dick Ameln <dick.ameln@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Co-authored-by: abc-125 <63813435+abc-125@users.noreply.github.com>
Co-authored-by: Harim Kang <harim.kang@intel.com>
Co-authored-by: Dick Ameln <amelndjd@gmail.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Blaz Rolih <blaz.rolih@gmail.com>
Co-authored-by: Adrian Boguszewski <adekboguszewski@gmail.com>
Co-authored-by: Willy Fitra Hendria <willyfitrahendria@gmail.com>
Co-authored-by: Samet Akcay <sakcay@Samets-MacBook-Pro.local>
Co-authored-by: Yunchu Lee <yunchu.lee@intel.com>
Co-authored-by: ggiret-thinkdeep <146845847+ggiret-thinkdeep@users.noreply.github.com>
Co-authored-by: Youho99 <gaylord.giret@viacesi.fr>
Co-authored-by: Philippe Carvalho <31983398+phcarval@users.noreply.github.com>
Co-authored-by: Wenjing Kang <wenjing.kang@intel.com>
Co-authored-by: FanJiangIntel <fan.jiang@intel.com>
Co-authored-by: belfner <belfner@belfner.com>
Co-authored-by: Abdulla Al Blooshi <76493346+abdullamatar@users.noreply.github.com>
Co-authored-by: Matías Tailanian <895687+mtailanian@users.noreply.github.com>
Co-authored-by: Jan Schlüter <github@jan-schlueter.de>
Co-authored-by: Christopher <48522299+holzweber@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants