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 validators #2305

Conversation

samet-akcay
Copy link
Contributor

📝 Description

  • Add validators
  • Convert private _validate methods to public validate methods
  • Following the new anomalib.data tree, restructure tests.

TODO:

  • Inherit Validator as a mixin class for each dataclass to not implement the validate methods explicitly.

WARNING
When reviewing the PR, it would be great to be as critical as possible, especially for the validator implementations.

✨ Changes

Select what type of change your PR is:

  • 🐞 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)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

djdameln and others added 27 commits September 2, 2024 12:07
* 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
* Reduce rich methods (openvinotoolkit#2283)

remove rich

Signed-off-by: Ashwin Vaidya <[email protected]>

* Refactor BaseThreshold to Threshold (openvinotoolkit#2278)

* Refactor BaseThreshold to Threshold

* Add relative import and add tests

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold.py to base.py

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold imports

Signed-off-by: Samet Akcay <[email protected]>

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

Co-authored-by: Ashwin Vaidya <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>

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

* pre-commit autoupdate

Signed-off-by: Samet Akcay <[email protected]>

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

* Add missing copyrights

Signed-off-by: Samet Akcay <[email protected]>

* Ignore copyrights in notebooks

* "PLW1514", # Add explicit encoding argument

Signed-off-by: Samet Akcay <[email protected]>

* "PLR6201", # Convert to set

Signed-off-by: Samet Akcay <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
* Reduce rich methods (openvinotoolkit#2283)

remove rich

Signed-off-by: Ashwin Vaidya <[email protected]>

* Refactor BaseThreshold to Threshold (openvinotoolkit#2278)

* Refactor BaseThreshold to Threshold

* Add relative import and add tests

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold.py to base.py

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold imports

Signed-off-by: Samet Akcay <[email protected]>

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

Co-authored-by: Ashwin Vaidya <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>

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

* pre-commit autoupdate

Signed-off-by: Samet Akcay <[email protected]>

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

* Add missing copyrights

Signed-off-by: Samet Akcay <[email protected]>

* Ignore copyrights in notebooks

* "PLW1514", # Add explicit encoding argument

Signed-off-by: Samet Akcay <[email protected]>

* "PLR6201", # Convert to set

Signed-off-by: Samet Akcay <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>

* Update docstring - FieldDescriptor

* Add docstring to generic.py

Signed-off-by: Samet Akcay <[email protected]>

* Add docstring to numpy.py

Signed-off-by: Samet Akcay <[email protected]>

* Add docstring to torch.py

Signed-off-by: Samet Akcay <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/generic.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Dick Ameln <[email protected]>

* Update src/anomalib/dataclasses/torch.py

Co-authored-by: Ashwin Vaidya <[email protected]>

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Dick Ameln <[email protected]>
* 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 <[email protected]>

---------

Co-authored-by: Ashwin Vaidya <[email protected]>
@djdameln djdameln force-pushed the feature/design-simplifications branch from 897b23b to 627be88 Compare September 12, 2024 15:17
@samet-akcay samet-akcay mentioned this pull request Sep 13, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants