anomalib icon indicating copy to clipboard operation
anomalib copied to clipboard

Allow passing metrics objects directly to `create_metrics_collection`

Open ashwinvaidya17 opened this issue 7 months ago โ€ข 1 comments

๐Ÿ“ Description

  • Adds the ability to pass metric objects directly.
  • Alternative to solution proposed in https://github.com/openvinotoolkit/anomalib/issues/2205

To test

from torchmetrics.classification import Accuracy, Precision, Recall

from anomalib.data import MVTec
from anomalib.engine import Engine
from anomalib.models import Padim

if __name__ == "__main__":
    model = Padim()
    data = MVTec()
    engine = Engine(image_metrics=[Accuracy(task="binary"), Precision(task="binary"), Recall(task="binary")])
    engine.train(model, datamodule=data)

โœจ Changes

Select what type of change your PR is:

  • [ ] ๐Ÿž Bug fix (non-breaking change which fixes an issue)
  • [x] ๐Ÿ”จ 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.

ashwinvaidya17 avatar Jul 24 '24 14:07 ashwinvaidya17