-
Notifications
You must be signed in to change notification settings - Fork 652
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
Dataclasses and post-processing refactor #2098
Dataclasses and post-processing refactor #2098
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave visualizer refactor to a different PR. It might require a lot more changes. We can just add a TODO to the comments in the inferencers.
The rest looks good to me. Once we remove the commented code we can push this as is.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/design-simplifications #2098 +/- ##
=================================================================
Coverage ? 80.00%
=================================================================
Files ? 250
Lines ? 11092
Branches ? 0
=================================================================
Hits ? 8874
Misses ? 2218
Partials ? 0 ☔ View full report in Codecov by Sentry. |
a298a3a
into
openvinotoolkit:feature/design-simplifications
* 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
* 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
📝 Description
Dataclasses:
anomalib.dataclasses
, which contains image and batch level dataclasses across different modalities.FieldDescriptor
class. This allows specifying a validation method for each field that gets called every time the field is updated. This ensures consistency in the typing and shape formatting of the fields of all instances of the dataclass.Post-processing:
PostProcessor
base class andOneClassPostProcessor
concrete subclass.PostProcessor
inherits fromCallback
, so post processing operations can easily be applied in any of the callback hooks.PostProcessor
inherits fromnn.Module
, so that the post-processing steps can be included in the forward pass of the exported model (onnx/torch/openvino). This means that subclasses ofPostProcessor
have to implement theforward
method. In the exported model, the post processor'sforward
method is called after the torch model'sforward
method.OneClassPostProcessor
class implements our previous post-processing behaviour, consisting of normalization and thresholding.post_processor
argument.✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.