Skip to content

Commit

Permalink
v2.0.0 (#2465)
Browse files Browse the repository at this point in the history
* Dataclasses and post-processing refactor (#2098)

* use dataclass for model in- and outputs

* split dataclass in image and video

* use dataclass in torch inferencer

* use dataclass in openvino inferencer

* add post_processor class

* remove default metrics from CLI

* export post processing

* add post processor to patchcore

* use named tuple for inference outputs

* validate and format inputs of PredictBatch

* update torch inference

* remove base inferencer inheritance

* update openvino inference

* fix visualization

* PredictBatch -> Batch

* post processor as callback

* use callback methods to apply post processing

* temporary fix for visualization

* add DatasetItem class

* fix pred_score shape and add __len__

* make batch iterable

* add in place replace method

* use dataset items in inference

* dataset_items -> items

* use namedtuple as torch model outputs

* formatting

* split dataclasses into input/output and image/video

* merge input and output classes

* use init_subclass for attribute checking

* add descriptor class for validation

* improve error handling

* DataClassDescriptor -> FieldDescriptor

* add is_optional method

* add input validation for torch image and batch

* use image and video dataclasses in library

* add more validation

* add validation

* make postprocessor configurable from engine

* fix post processing logic

* fix data tests

* remove detection task type

* fix more tests

* use separate normalization stats for image and pixel preds

* add sensitivity parameters to one class pp

* fix utils tests

* fix utils tests

* remove metric serialization test

* remove normalization and thresholding args

* set default post processor in base model

* remove manual threshold test

* fix remaining unit tests

* add post_processor to CLI args

* remove old post processing callbacks

* remove comment

* remove references to old normalization and thresholding callbacks

* remove reshape in openvino inferencer

* export lightning model directly

* make collate accessible from dataset

* fix tools integration tests

* add update method to dataclasses

* allow missing pred_score or anomaly_map in post processor

* fix exportable centercrop conversion

* fix model tests

* test all models

* fix efficient_ad

* post processor as model arg

* disable rkde tests

* fix winclip export

* add copyright notice

* add validation for numpy anomaly map

* fix getting started notebook

* remove hardcoded path

* update dataset notebooks

* update model notebooks

* fix logging notebooks

* fix model notebook

* Merge main and resolve conflicts (#2287)

* Reduce rich methods (#2283)

remove rich

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Refactor BaseThreshold to Threshold (#2278)

* Refactor BaseThreshold to Threshold

* Add relative import and add tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert threshold.py to base.py

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert threshold imports

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update tests/unit/metrics/threshold/test_threshold.py

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

---------

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

* Enable Ruff Rules: PLW1514 and PLR6201 (#2284)

* pre-commit autoupdate

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Enable preview feautures, and disable some of the updated features

* Add missing copyrights

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Ignore copyrights in notebooks

* "PLW1514", # Add explicit encoding argument

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* "PLR6201", # Convert to set

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

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

* Rename Item to DatasetItem (#2289)

* 📚 Add docstrings to dataclasses (#2292)

* Reduce rich methods (#2283)

remove rich

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Refactor BaseThreshold to Threshold (#2278)

* Refactor BaseThreshold to Threshold

* Add relative import and add tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert threshold.py to base.py

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert threshold imports

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update tests/unit/metrics/threshold/test_threshold.py

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

---------

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

* Enable Ruff Rules: PLW1514 and PLR6201 (#2284)

* pre-commit autoupdate

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Enable preview feautures, and disable some of the updated features

* Add missing copyrights

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Ignore copyrights in notebooks

* "PLW1514", # Add explicit encoding argument

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* "PLR6201", # Convert to set

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update docstring - FieldDescriptor

* Add docstring to generic.py

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add docstring to numpy.py

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add docstring to torch.py

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/generic.py

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

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/torch.py

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

* Update src/anomalib/dataclasses/torch.py

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

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: Samet Akcay <samet.akcay@intel.com>
Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Co-authored-by: Dick Ameln <amelndjd@gmail.com>

* Refactor and restructure anomalib.data (#2302)

* Move datamodules to datamodule sub-package

* Move datamodules to datamodule sub-package

* Split datamodules and datasets

* Restructure dataclasses to data

* Fix relative imports

* Use absolute imports

* Add datasets dir

* Add relative imports for torch datasets

* Update src/anomalib/data/datamodules/base/__init__.py

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

---------

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

* Restructure unit tests and fix ruff issues (#2306)

* Restructure data unit tests to follow the new data structure

* Fix ruff issues

* Add dataclass validators (#2307)

* Add validators

* Add depth validators to depth classes

* Add image validators to depth classes

* Add video validators to depth classes

* Add numpy validators and update dataclasses

* Run all the tests on the ci

* Fix the tests

* Created validator tests and added numpy video tests

* Add numpy image tests

* Add numpy depth tests

* Add torch validator tests

* Fix numpy validation tests

* Convet private _validate methods to public validate method

* Revert "Convet private _validate methods to public validate method"

This reverts commit 47f183a8495b13085f2046ccd719eb4d3c4add48.

* Convert private _validate methods to public validate method

* Remove batch_size arg from validators

* Remove anomaly_map from validators

* Use validators as mixins

* convert abstractmethods to static abstractmethods

* Move pred-score computation to model implementations

* Add missing pred_score implemenations in models

* Fix the numpy validation tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix visualization tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add numpy video validator mixin to numpy video item, and remove validation methods

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add np.bool_ to validate np label

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* 🚀 Customisable Image Visualizer (#2334)

* Add validators

* Add depth validators to depth classes

* Add image validators to depth classes

* Add video validators to depth classes

* Add numpy validators and update dataclasses

* Run all the tests on the ci

* Fix the tests

* Created validator tests and added numpy video tests

* Add numpy image tests

* Add numpy depth tests

* Add torch validator tests

* Fix numpy validation tests

* Convet private _validate methods to public validate method

* Revert "Convet private _validate methods to public validate method"

This reverts commit 47f183a8495b13085f2046ccd719eb4d3c4add48.

* Convert private _validate methods to public validate method

* Remove batch_size arg from validators

* Remove anomaly_map from validators

* Use validators as mixins

* convert abstractmethods to static abstractmethods

* Move pred-score computation to model implementations

* Add missing pred_score implemenations in models

* Fix the numpy validation tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix visualization tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add numpy video validator mixin to numpy video item, and remove validation methods

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add np.bool_ to validate np label

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* add convert_to_title_case function to path utils

* Add ImageVisualizer

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Create image visualization functionals

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Create image visualization class

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add a comment in visualize-item

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update functional.py

* Add warning for invalid overlays

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add overlay_mask function with fill and contour modes

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Moved `visualize_image_item` to a new module

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix typo in visualizer

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Pass mask color to visualize_mask

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Modify item_visualizer

Signed-off-by: Samet Akcay <sakcay@MV23WXK0MRmac.local>

* Update visualize item

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update the item visualization

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update the item visualization

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>
Signed-off-by: Samet Akcay <sakcay@MV23WXK0MRmac.local>
Co-authored-by: Samet Akcay <sakcay@MV23WXK0MRmac.local>

* Merge main the feature branch. (#2376)

* Update timm requirement from <=1.0.7,>=1.0.7 to >=1.0.7,<=1.0.9 (#2274)

* Update timm requirement from <=1.0.7,>=1.0.7 to >=1.0.7,<=1.0.9

Updates the requirements on [timm](https://github.com/huggingface/pytorch-image-models) to permit the latest version.
- [Release notes](https://github.com/huggingface/pytorch-image-models/releases)
- [Commits](https://github.com/huggingface/pytorch-image-models/compare/v1.0.7...v1.0.9)

---
updated-dependencies:
- dependency-name: timm
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pyproject.toml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🐞Update `setuptools` requirement for PEP 660 support (#2320)

Update setup tools

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix transforms for draem, dsr and rkde (#2324)

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Add check before loading metrics data from checkpoint (#2323)

Add check before loading from checkpoint

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Add PIMO (#2329)

* PIMO (#1726)

* update

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* test binclf curves numpy and numba and fixes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct som docstrings

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* torch interface and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* torch interface and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* constants regrouped in dataclass as class vars

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* result class was unneccesary for per_image_binclf_curve

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* factorize function _get_threshs_minmax_linspace

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* small docs fixes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add pimo numpy version and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* move validation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add `shared_fpr_metric` option

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add pimo torch functional version and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add torchmetrics interface and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* renames and put things in init

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* validate inputs in result objects

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* result objects to from dict and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add save and load methods to result objects and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor validations and minor changes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* test result objects' properties

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor refactors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add missing docstrings

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minore vocabulary fix for consistency

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add per image scores statistics and test it

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor constants notation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add stats tests and test it

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* change the meaning of AUPIMO.num_thresh

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* interface to format pairwise test results

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* improve doc

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add optional `paths` to result objects and some minor fixes and refactors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove frozen from dataclasses and some done todos

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* review headers

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* doc modifs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor `score_less_than_thresh` in `_binclf_one_curve_python`

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct license comments

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix doc

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* numba as extra requirement

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor copyrights from jpcbertoldo

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove from __future__ import annotations

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor validations names

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* dedupe file path validation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Add todo

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor enums

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* only logger.warning

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor test imports

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor docs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor some docs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct pre commit errors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove author tag

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add thrid party program

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Update src/anomalib/metrics/per_image/pimo.py

* move HAS_NUMBA

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove PIMOSharedFPRMetric

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* make torchmetrics compute avg by dft

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* pre-commit hooks corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct numpy.trapezoid

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🗑️ Remove numba (#2313)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* add third-party-programs.txt

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🗑️ Remove unused methods (#2315)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PIMO: Port Numpy → Torch (#2316)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* replace numpy with torch

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🔨Refactor methods across files (#2321)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* replace numpy with torch

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactor code

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactor
move functional inside update
remove path from the metric

* Add changes from comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove model to model comparison (#2325)

* rename to pimo

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* minor refactor

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove model to model comparison

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix test

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Minor refactor

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove unused enums

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* update doc strings

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* update param names

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* add aupimo basic usage tutorial notebook (#2330)

* add aupimo basic usage tutorial notebook

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update scipy import

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add cite us

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify texts and add illustration

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* udpate working dir

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Co-authored-by: Joao P C Bertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Makes batch size dynamic (#2339)

Made batch dimension of ONNX export dynamic when specifying input shape.

* Add pimo tutorial advanced i (fixed) (#2336)

* uset all padim features to make it deterministic

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced i

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify changelog

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct again

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Pimo tutorials/02 advanced ii (#2347)

* uset all padim features to make it deterministic

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced i

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify changelog

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct again

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced ii (pimo curve and integration bounds)

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix links

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct change log

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Create epic.yaml

* 🔨 Update the issue templates (#2363)

* Update epic.yaml

* Update epic.yaml

* Update epic.yaml

* Update epic.yaml

* Update task.yaml

* Create user_story.yaml

* Update epic.yaml

* Pimo tutorials/03 advanced iii (#2348)

* add aupimo notebook advanced iii (aupimo score of a random model)

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add cite us

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update notebooks readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🔨 Deprecate try import and replace it with Lightning's package_available (#2373)

Replace try_import with lightnings package_available function

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Refactor folder3d to avoid complex-structure (C901) issue (#2185)

* Refactored-make_folder3d_dataset-ruff-error-C901 (#1926)

Signed-off-by: sahusiddharth <siddharth.sahu@plaksha.edu.in>

* Simplify folder 3d dataset (#2184)

---------

Signed-off-by: sahusiddharth <siddharth.sahu@plaksha.edu.in>
Co-authored-by: Siddharth Sahu <112792547+sahusiddharth@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Samet Akcay <samet.akcay@intel.com>
Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Signed-off-by: sahusiddharth <siddharth.sahu@plaksha.edu.in>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Blaž Rolih <61357777+blaz-r@users.noreply.github.com>
Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Co-authored-by: Joao P C Bertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Marcus Pertlwieser <116986601+Marcus1506@users.noreply.github.com>
Co-authored-by: Siddharth Sahu <112792547+sahusiddharth@users.noreply.github.com>

* Metrics redesign (#2326)

* refactor metrics callback

* add Evaluator class

* remove unused import

* add AnomalibMetric base class

* cleanup

* add create_anomalib_metric function

* use new AnomalibMetric class

* verify keys when updating metric

* use anomalib PR curve for f1max

* replace evaluator with metrics arg

* revert removing exportable transform method

* fix unit tests

* add kwargs to lightning models

* fix pre-commit issues

* remove kwargs key from update config

* add Evaluator to metrics init

* set default evaluator for image-only models

* fix cfa tests

* fix model tests

* update changelog

* remove tests of deprecated callback modules

* fix engine tests

* fix 201 notebook

* fix 600 notebook

* add default evaluator to fastflow

* revert cfa changes and fix pred score computation

* simplify evaluator argument

* validate metrics in evaluator

* remove unused import

* fix pred_label shape validation

* fix method name

* fix pred_label validator

* update validator tests

* fix method name in fastflow

* add AnomalibMetric functionality to PIMO

* add optional default fields and implement for pimo

* update aupimo notebooks

* use explicit args in lightning model signature

* remove kwargs from evaluator

* add _resolve_evaluator method

* fix config upgrade test

* do not force pypi install in mlflow notebook

* do not force pypi install in mlflow notebook

* 🚀 Add `PreProcessor` to `AnomalyModule` (#2358)

* Created pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Rename transforms to transform in pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datasets

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove setup_transforms from Engine

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add preprocessor to AnomalyModule and models

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove self._transform from AnomalyModule

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* revert transforms in datasets

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* fix efficient_ad and engine.config tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update the upgrade tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert on_load_checkpoint hook to AnomalyModule

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove exportable transform from anomaly module and move to pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add pre-processor to the model graph

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add docstring to pre-processor class

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix win-clip tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update notebooks

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Split the forward logic and move the training to model hooks

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Set data transforms from preprocessor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update the docstrings

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Get stage transforms in setup of pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert data config yaml files

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert datasets

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert notebooks

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* remove padim preprocessor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update the setup logic in pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Set datamodule transforms property from preprocessor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Revert v1 upgrade tool

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix aupimo notebooks

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add pre-processor unit tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Increase the test coverage for PreProcessor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Add option to disable pre-processor

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Split setup_transforms to setup_datamodule_transforms and setup_dataloader_transforms

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Replace batch.update with in-place batch transforms

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove logger.warning when the default pre-processor is used

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Use predict-transforms explicitly

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* remove pre-processor and configure_transforms from export mixin

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Rename set_datamodule_transform to set_datamodule_stage_transform

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transforms from datamodules

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove transform related keys from data configs

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* update preprocessor tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove setup method from the model implementations

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove image size from datamodules in jupyter notebooks

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Modify folder notebook to acccess the batch from dataset not dataloader

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Create resolve preprocessor method

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Return  if  is

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Rename self.exportable_transform to self.export_transform

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Remove set_datamodule_transforms

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* remove hooks as they are not needed anymore

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix pre-processor tests

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* remove transform getter util function

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix transform dict to setup datamodule transforms

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix Fastflow notebook

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Update v2 with the recent changes on main (#2421)

* Update timm requirement from <=1.0.7,>=1.0.7 to >=1.0.7,<=1.0.9 (#2274)

* Update timm requirement from <=1.0.7,>=1.0.7 to >=1.0.7,<=1.0.9

Updates the requirements on [timm](https://github.com/huggingface/pytorch-image-models) to permit the latest version.
- [Release notes](https://github.com/huggingface/pytorch-image-models/releases)
- [Commits](https://github.com/huggingface/pytorch-image-models/compare/v1.0.7...v1.0.9)

---
updated-dependencies:
- dependency-name: timm
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pyproject.toml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🐞Update `setuptools` requirement for PEP 660 support (#2320)

Update setup tools

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix transforms for draem, dsr and rkde (#2324)

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Add check before loading metrics data from checkpoint (#2323)

Add check before loading from checkpoint

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Add PIMO (#2329)

* PIMO (#1726)

* update

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* test binclf curves numpy and numba and fixes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct som docstrings

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* torch interface and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* torch interface and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* constants regrouped in dataclass as class vars

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* result class was unneccesary for per_image_binclf_curve

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* factorize function _get_threshs_minmax_linspace

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* small docs fixes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add pimo numpy version and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* move validation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add `shared_fpr_metric` option

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add pimo torch functional version and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add torchmetrics interface and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* renames and put things in init

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* validate inputs in result objects

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* result objects to from dict and tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add save and load methods to result objects and test

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor validations and minor changes

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* test result objects' properties

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor refactors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add missing docstrings

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minore vocabulary fix for consistency

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add per image scores statistics and test it

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor constants notation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add stats tests and test it

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* change the meaning of AUPIMO.num_thresh

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* interface to format pairwise test results

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* improve doc

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add optional `paths` to result objects and some minor fixes and refactors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove frozen from dataclasses and some done todos

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* review headers

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* doc modifs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor `score_less_than_thresh` in `_binclf_one_curve_python`

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct license comments

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix doc

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* numba as extra requirement

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor copyrights from jpcbertoldo

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove from __future__ import annotations

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor validations names

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* dedupe file path validation

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix tests

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Add todo

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor enums

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* only logger.warning

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor test imports

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor docs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* refactor some docs

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct pre commit errors

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove author tag

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add thrid party program

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Update src/anomalib/metrics/per_image/pimo.py

* move HAS_NUMBA

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* remove PIMOSharedFPRMetric

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* make torchmetrics compute avg by dft

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* pre-commit hooks corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct numpy.trapezoid

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🗑️ Remove numba (#2313)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* add third-party-programs.txt

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🗑️ Remove unused methods (#2315)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PIMO: Port Numpy → Torch (#2316)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* replace numpy with torch

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🔨Refactor methods across files (#2321)

* remove numba

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix pre-commit checks

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove all unused methods

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* replace numpy with torch

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactor code

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* refactor
move functional inside update
remove path from the metric

* Add changes from comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove model to model comparison (#2325)

* rename to pimo

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* minor refactor

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove model to model comparison

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* fix test

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Minor refactor

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove unused enums

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* update doc strings

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* update param names

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* add aupimo basic usage tutorial notebook (#2330)

* add aupimo basic usage tutorial notebook

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update scipy import

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add cite us

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify texts and add illustration

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* udpate working dir

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Co-authored-by: Joao P C Bertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Makes batch size dynamic (#2339)

Made batch dimension of ONNX export dynamic when specifying input shape.

* Add pimo tutorial advanced i (fixed) (#2336)

* uset all padim features to make it deterministic

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced i

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify changelog

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct again

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Pimo tutorials/02 advanced ii (#2347)

* uset all padim features to make it deterministic

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced i

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* modify changelog

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct again

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* minor corrections

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced ii (pimo curve and integration bounds)

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix links

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* correct change log

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* Create epic.yaml

* 🔨 Update the issue templates (#2363)

* Update epic.yaml

* Update epic.yaml

* Update epic.yaml

* Update epic.yaml

* Update task.yaml

* Create user_story.yaml

* Update epic.yaml

* Pimo tutorials/03 advanced iii (#2348)

* add aupimo notebook advanced iii (aupimo score of a random model)

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add cite us

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* update notebooks readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🔨 Deprecate try import and replace it with Lightning's package_available (#2373)

Replace try_import with lightnings package_available function

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Refactor folder3d to avoid complex-structure (C901) issue (#2185)

* Refactored-make_folder3d_dataset-ruff-error-C901 (#1926)

Signed-off-by: sahusiddharth <siddharth.sahu@plaksha.edu.in>

* Simplify folder 3d dataset (#2184)

---------

Signed-off-by: sahusiddharth <siddharth.sahu@plaksha.edu.in>
Co-authored-by: Siddharth Sahu <112792547+sahusiddharth@users.noreply.github.com>

* 🚀 Add datumaro annotation dataloader (#2377)

* Add datumaro annotation dataloader

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update changelog

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add examples

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Pimo tutorials/04 advanced iv  (#2352)

* add notebook 701e_aupimo_advanced_iv on load/save and statistical comparisons

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* make `AUPIMOResult.num_thresholds` optional

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* add aupimo notebook advanced iv (load/save and statistical tests)

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* simplify cite us and mention intal

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

* fix readme

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>

---------

Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* 🐞 Defer OpenVINO import to avoid unnecessary warnings (#2385)

* Fix openvino import issue

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* Fix pre-commit issues

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

---------

Signed-off-by: Samet Akcay <samet.akcay@intel.com>

* 🚀 Add VLM based Anomaly Model (#2344)

* [Draft] Llm on (#2165)

* Add TaskType Explanation

Signed-off-by: Bepitic <bepitic@gmail.com>

* Add llm model

Signed-off-by: Bepitic <bepitic@gmail.com>

* add ollama

Signed-off-by: Bepitic <bepitic@gmail.com>

* better description for descr in title

Signed-off-by: Bepitic <bepitic@gmail.com>

* add text of llm into imageResult visualization

* add text of llm into imageResult visualization

Signed-off-by: Bepitic <bepitic@gmail.com>

* latest changes

Signed-off-by: Bepitic <bepitic@gmail.com>

* add wip llava/llava_next

Signed-off-by: Bepitic <bepitic@gmail.com>

* add init

Signed-off-by: Bepitic <bepitic@gmail.com>

* add text of llm into imageResult visualization

Signed-off-by: Bepitic <bepitic@gmail.com>

* latest changes

Signed-off-by: Bepitic <bepitic@gmail.com>

* upd Lint

Signed-off-by: Bepitic <bepitic@gmail.com>

* fix visualization with description

Signed-off-by: Bepitic <bepitic@gmail.com>

* show the images every batch

Signed-off-by: Bepitic <bepitic@gmail.com>

* fix docstring and error management

Signed-off-by: Bepitic <bepitic@gmail.com>

* Add compatibility for TaskType.EXPLANATION.

Signed-off-by: Bepitic <bepitic@gmail.com>

* Remove, show in the engine-Visualization.

* fix visualization and llm openai multishot.

* fix Circular import problem

* Add HugginFace To LLavaNext

Signed-off-by: Bepitic <bepitic@gmail.com>

---------

Signed-off-by: Bepitic <bepitic@gmail.com>

* 🔨 Scaffold for refactor (#2340)

* initial scafold

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* rename dir

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add ChatGPT (#2341)

* initial scafold

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* rename dir

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* delete llm_ollama

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add ChatGPT

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add ChatGPT

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove LLM model

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add Huggingface (#2343)

* initial scafold

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Apply PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* rename dir

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* delete llm_ollama

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add ChatGPT

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add ChatGPT

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove LLM model

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add transformers

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Remove llava

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🔨 Minor Refactor (#2345)

Refactor

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* undo changes

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* undo changes

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* undo changes to image.py

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Add explanation visualizer (#2351)

* Add explanation visualizer

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* bug-fix

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🔨 Allow setting API keys from env (#2353)

Allow setting API keys from env

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* 🧪 Add tests (#2355)

* Add tests

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* remove explanation task type

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* minor fixes

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update changelog

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Fix tests

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Address PR comments

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* update name

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

* Update src/anomalib/models/image/vlm_ad/lightning_model.py

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

* update name

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>

---------

Signed-off-by: Bepitic <bepitic@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
Co-authored-by: Paco <bepitic@gmail.com>
Co-authored-by: Samet Akcay <samet.akcay@intel.com>

* Add ensembling methods for tiling to Anomalib (#1226)

* Fixed broken links in readme

* Fixed inference command in readme

* Add tiling for ensemble

* Add tests for tiling for ensemble

* Moved ensemble tiler to separate file

* Modify padim config for ensemble

* Add tiling to dataset

* Revert changes to train

* Add tiling to collate fn

* Fix tiling in collate

* Change val. function to protected

* Add tile number logic

* Move collate fn to separate file

* Update tests for tiler

* Add training loop for ensemble

* Add model input size setup

* Move ens config to separate file

* Revert mvtec modifications

* Remove unused imports in mvtec

* Add batch adjustment to untiling

* Add predict step to ensemble

* Add comment and docstring to tile joining function

* Move tile joining to separate function

* Add joining for all tiled data

* Add joining for all box data

* Refactor pred. joining as modular class

* Fix box joining

* Add label and score joining

* Add ensemble visualization

* Add end of predict hook

* Add metric computation

* Fix metric thresholds

* Add removal of individual visualization

* Add demo1 notebook

* Add docstrings and cleanup

* Add memory benchmark

* Add modular class for storing predictions

* Add metric to separate class

* Refactor to support prediction data class

* Rename predictions class

* Add filesystem predictions class

* Add resized predictions class

* Fix joiner for classification task

* Add page peak to memory benchmark

* Add global stats calculation

* Add docstrings to stats calculation

* Refactor joiner for pipeline

* Refactor stats into pipeline

* Refactor metrics as pipeline block

* Refactor visualization as pipeline block

* Refactor postprocessing into a pipeline

* Add normalization and thresholding on joined predictions

* Refactor tiler to accept config file

* Add smoothing of tile joins.

* Refactor ensemble datamodule preparation

* Remove unused changes in dataloader

* Fix metric configuration

* Fix box coordinates in joining

* Add ensemble callbacks preparation function

* Fix box prediction bug in postprocess

* Add ensemble params to config

* Refactor postprocessing.

* Refactor post-processing

* Refactor predictions

* Code cleanup

* Optimize prediction storage

* Make join smoothing configurable

* Cleanup before PR

* Fix stats pipeline

* Fix logging strings

* Fix memory benchmark

* Fix tiler issues

* Fix import issues

* Fix naming in metrics and visualization

* Fix cyclic import

* Make logging lazy

* Refactor tiler tests

* Added collate tiling tests

* Added ensemble helper functions tests

* Refactor for dummy ensemble config

* Refactor for dummy base config

* Add tests for prediction storage

* Add tests for prediction joiner

* Add tests for visualization

* Fix small issues in tests

* Add metrics test

* Add post-processing tests

* Fix tiler to work with different instance

* Move seed setting inside train loop

* Fix pipeline stats bug

* Rename ensemble config fixture

* Add pipeline tests

* Fix config in pipeline tests

* Add training script test

* Fix types and docstrings

* Move and rename to tiled_ensemble

* Fix bug in label joining.

* Remove memory benchmark

* Cleanup files

* Fix metrics setup

* Rename collate function

* Add license to test files

* Rename fixtures

* Add more comments to tiled ensemble training

* Add start of training log message

* Refactor tiler to have explicit arguments

* Refactor pred. storage to have explicit arguments

* Refactor metrics to have explicit arguments

* Refactor visualization to have explicit arguments

* Refactor post-processing to have explicit arguments

* Sort imports

* Add test ensemble script

* Fix join smoothing bug

* Add more documentation to doc-strings

* Remove unused import

* Add brief tiled ensemble documentation

* Update typehints

* Make training args more clear

* Revert addition of no threshold option.

* Refactor normalization and threshold config

* Remove tiled ensemble from docs index

* Add comments to clarify parts of ensemble config

* Improve ensemble config comments

* Add num_tiles attribute to tiler.

* Fix metrics process docstring

* Fix visualization bug and cover with test

* Replace strings with enum

* Improve comments in joiner.

* Fix bug when model doesn't have anomaly maps.

* Improve docstrings (types, clarify).

* Fix visualization tests

* Fix dict membership checks

* Add saving of ensemble config file

* Update test script args

* Cover test script with tests

* Update export warning

* Fix case when no test or val data

* Improve documentation images

* Add images for documentation

* Add codacy suggestion

* Refactor joiner to single class

* Refactor storage names and config

* Update normalization and threshold stage names

* Add transforms independent input size to models

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Make collate function a datamodule attribute

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor tiled ensemble train into pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor tiled ensemble prediction into pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor tiled ensemble merging into pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor tiled ensemble seam smoothing into pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor tiled stats calculation into pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Fix ckpt loading when predicting on test set.

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Add logging and add tqdm to pipeline steps.

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor normalization pipeline step

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Refactor thresholding into new pipeline job

* Fix transforms issue when predicting with dataloader

* Add visualization as new pipeline step

* Add metrics as new pipeline step

* Format the code and address some lint problems

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Add code to skip test if test split is none

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Add accelerator to metrics and smoothing

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Make threshold acq helper function and add to threshold to metrics

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Make a separate test pipeline

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Restructure tiled ensemble files into directories

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Pipeline code cleanup

Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>

* Remove old tiled ensemble files

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Remove old post processing files

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Fix sigma value read in smoothing

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Update stats calc and normalization

Signed-off-by: blaz-r <blaz.rolih@gmail.com>

* Update args naming convention

Signed-off-by: blaz-r <blaz.rolih@gmail.com>
…
  • Loading branch information
14 people authored Jan 8, 2025
1 parent bcc0b43 commit 084331d
Show file tree
Hide file tree
Showing 665 changed files with 49,417 additions and 27,075 deletions.
408 changes: 0 additions & 408 deletions .ci/ipas_default.config

This file was deleted.

11 changes: 0 additions & 11 deletions .ci/trivy.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

# Ignore *ipynb files to detect the language.
# This is because GitHub misdetects the repo language when ipynb files are included.
*.ipynb linguist-detectable=false
*.ipynb filter=lfs diff=lfs merge=lfs -text
14 changes: 6 additions & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
/docs @samet-akcay

# Notebooks
/notebooks/000_getting_started @samet-akcay
/notebooks/100_datamodules @djdameln
/notebooks/200_models @samet-akcay
/notebooks/300_benchmarking @ashwinvaidya17
/notebooks/400_openvino @samet-akcay
/notebooks/500_use_cases @paularamo
/notebooks/README.md @samet-akcay
/examples/notebooks/000_getting_started @samet-akcay
/examples/notebooks/100_datamodules @djdameln
/examples/notebooks/200_models @samet-akcay
/examples/notebooks/300_benchmarking @ashwinvaidya17
/examples/notebooks/400_openvino @samet-akcay
/examples/notebooks/README.md @samet-akcay

# Requirements
/requirements/ @samet-akcay @ashwinvaidya17 @djdameln
Expand All @@ -41,7 +40,6 @@
/src/anomalib/models/padim @samet-akcay
/src/anomalib/models/patchcore @djdameln
/src/anomalib/models/reverse_distillation @ashwinvaidya17
/src/anomalib/models/rkde @djdameln
/src/anomalib/models/stfpm @samet-akcay

/src/anomalib/post_processing @ashwinvaidya17 @djdameln
Expand Down
116 changes: 116 additions & 0 deletions .github/actions/code-quality/pre-commit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Pre-commit Quality Action
#
# This composite action executes pre-commit hooks for code quality checks
# with configurable Python and Node.js environments.
#
# Key Features:
# - Pre-commit hook execution
# - Environment configuration
# - Cache management
# - Multi-language support
# - Dependency handling
#
# Process Stages:
# 1. Environment Setup:
# - Python installation
# - Node.js installation
# - Cache configuration
#
# 2. Dependency Management:
# - Pre-commit installation
# - Hook installation
# - Cache restoration
#
# 3. Quality Checks:
# - Hook execution
# - Error reporting
# - Result caching
#
# Required Inputs:
# - python-version: Python version to use
# - node-version: Node.js version to use (defaults to "20")
#
# Example Usage:
# steps:
# - uses: ./.github/actions/code-quality/pre-commit
# with:
# python-version: "3.11"
#
# Note: Requires configured pre-commit hooks in repository

name: "Pre-commit Quality Checks"
description: "Runs pre-commit hooks for code quality checks"

inputs:
python-version:
description: "Python version to use"
required: false
default: "3.10"
node-version:
description: "Node.js version to use"
required: false
default: "20"
skip:
description: "Comma-separated list of hooks to skip"
required: false
default: ""
cache:
description: "Whether to use caching"
required: false
default: "true"

outputs:
cache-hit:
description: "Whether the cache was hit"
value: ${{ steps.pre-commit-cache.outputs.cache-hit }}

runs:
using: composite
steps:
# Set up Python environment with caching
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: pip # Enable pip caching
cache-dependency-path: .pre-commit-config.yaml

# Set up Node.js for JavaScript-related hooks
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

# Install pre-commit with latest pip
- name: Install pre-commit
shell: bash
run: |
python -m pip install --upgrade pip
pip install pre-commit
# Cache pre-commit hooks to speed up subsequent runs
- name: Cache pre-commit hooks
if: inputs.cache == 'true'
id: pre-commit-cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
# Cache key includes Python and Node versions to ensure correct environment
key: pre-commit-${{ runner.os }}-py${{ inputs.python-version }}-node${{ inputs.node-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-py${{ inputs.python-version }}-node${{ inputs.node-version }}-
pre-commit-${{ runner.os }}-py${{ inputs.python-version }}-
# Execute pre-commit checks with optional hook skipping
- name: Run pre-commit checks
shell: bash
env:
SKIP: ${{ inputs.skip }}
run: |
if [ -n "$SKIP" ]; then
# Run specific hooks if skip parameter is provided
pre-commit run --all-files --hook-stage="$SKIP"
else
# Run all hooks if no skip parameter
pre-commit run --all-files
fi
217 changes: 217 additions & 0 deletions .github/actions/pytest/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Test Runner Action
#
# This composite action executes Python tests with pytest, providing
# comprehensive test execution and reporting capabilities.
#
# Key Features:
# - Multiple test type support
# - Parallel execution
# - Coverage reporting
# - Performance tracking
# - Result analysis
#
# Process Stages:
# 1. Environment Setup:
# - Python configuration
# - Virtual environment creation
# - Dependency installation
#
# 2. Test Execution:
# - Test scope determination
# - Parallel processing
# - Coverage tracking
# - Performance monitoring
#
# 3. Results Processing:
# - Coverage analysis
# - Performance reporting
# - Results aggregation
#
# Required Inputs:
# - python-version: Python version for tests
# - test-type: Type of tests to run
# - codecov-token: Token for coverage upload
# - max-test-time: Maximum test duration
# - device: Device to run tests on (cpu/gpu)
# - enable-cache: Enable pip caching
#
# Outputs:
# - coverage-percentage: Total coverage
# - tests-passed: Test success status
# - test-duration: Execution time
#
# Example Usage:
# steps:
# - uses: ./.github/actions/pytest
# with:
# python-version: "3.11"
# test-type: "unit"
# codecov-token: ${{ secrets.CODECOV_TOKEN }}
#
# Note: Requires proper pytest configuration in pyproject.toml

name: "Python Tests Runner"
description: "Runs Python unit and integration tests with pytest and uploads coverage to Codecov"

inputs:
python-version:
description: "Python version to use"
required: false
default: "3.10"
test-type:
description: "Type of tests to run (unit/integration/all)"
required: false
default: "all"
codecov-token:
description: "Codecov upload token"
required: true
max-test-time:
description: "Maximum time in seconds for the test suite to run"
required: false
default: "3600"
device:
description: "Device to run tests on (cpu/gpu)"
required: false
default: "gpu"
enable-cache:
description: "Enable pip caching"
required: false
default: "true"

outputs:
coverage-percentage:
description: "Total coverage percentage"
value: ${{ steps.coverage.outputs.percentage }}
tests-passed:
description: "Whether all tests passed"
value: ${{ steps.test-execution.outputs.success }}
test-duration:
description: "Total test duration in seconds"
value: ${{ steps.test-execution.outputs.duration }}

runs:
using: composite
steps:
# Set up Python with pip caching
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: ${{ inputs.enable-cache == 'true' && 'pip' || '' }}
cache-dependency-path: ${{ inputs.enable-cache == 'true' && 'pyproject.toml' || '' }}

# Create and configure virtual environment
- name: Configure virtual environment
id: setup-venv
shell: bash
run: |
# Create isolated test environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies with dev extras
python -m pip install --upgrade pip
pip install ".[dev]"
pip install codecov
# Determine which tests to run based on input
- name: Determine test scope
id: test-scope
shell: bash
run: |
case "${{ inputs.test-type }}" in
"unit")
echo "path=tests/unit" >> $GITHUB_OUTPUT
;;
"integration")
echo "path=tests/integration" >> $GITHUB_OUTPUT
;;
*)
# Run both test types if not specified
echo "path=tests/unit tests/integration" >> $GITHUB_OUTPUT
;;
esac
- name: Execute test suite
id: test-execution
shell: bash
continue-on-error: true
run: |
source .venv/bin/activate
start_time=$(date +%s)
# Set device-specific pytest arguments
if [ "${{ inputs.device }}" = "cpu" ]; then
marker="-m cpu" # Only run CPU tests
else
marker="" # Run all tests (both CPU and GPU marked tests)
fi
# Run pytest
PYTHONPATH=src pytest ${{ steps.test-scope.outputs.path }} \
--numprocesses=0 \
--durations=10 \
--durations-min=1.0 \
--timeout=${{ inputs.max-test-time }} \
--verbosity=1 \
--cov=src \
--cov-report=xml \
--cov-report=term-missing \
${marker}
test_exit_code=${PIPESTATUS[0]}
# Calculate and store duration
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "duration=$duration" >> $GITHUB_OUTPUT
echo "success=$([[ $test_exit_code == 0 ]] && echo true || echo false)" >> $GITHUB_OUTPUT
# Store test results summary
if [ $test_exit_code -ne 0 ]; then
echo "::error::Tests failed. See summary below:"
echo "----------------------------------------"
# Extract the summary section from pytest output
sed -n '/=* short test summary info =*/,$p' pytest_output.log || true
echo "----------------------------------------"
echo "Full test output saved to artifacts"
fi
exit $test_exit_code
- name: Upload test results
if: always() && steps.test-execution.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ inputs.test-type }}
path: pytest_output.log
retention-days: 7

- name: Check test results
if: always() && steps.test-execution.outcome == 'failure'
shell: bash
run: exit 1

- name: Check test duration
if: always()
shell: bash
run: |
duration="${{ steps.test-execution.outputs.duration }}"
if [ -n "$duration" ]; then
echo "Test Duration: $duration seconds"
if [ "$duration" -gt "${{ inputs.max-test-time }}" ]; then
echo "::warning::Test suite exceeded recommended duration of ${{ inputs.max-test-time }} seconds"
fi
else
echo "Test Duration: Not available"
fi
- name: Upload coverage to Codecov
if: success()
shell: bash
run: |
source .venv/bin/activate
codecov --token "${{ inputs.codecov-token }}" \
--file coverage.xml \
--flags "${{ inputs.test-type }}_py${{ inputs.python-version }}" \
--name "${{ inputs.test-type }} tests (Python ${{ inputs.python-version }})"
Loading

0 comments on commit 084331d

Please sign in to comment.