Skip to content

Commit

Permalink
Set full_state_update attribute in custom metrics (#531)
Browse files Browse the repository at this point in the history
* add full_state_update attribute to metrics

* upgrade torchmetrics

* allow range of torchmetrics versions

Co-authored-by: Samet Akcay <samet.akcay@intel.com>
  • Loading branch information
djdameln and samet-akcay committed Sep 2, 2022
1 parent bd36919 commit 36ac8cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions anomalib/utils/metrics/min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class MinMax(Metric):
"""Track the min and max values of the observations in each batch."""

full_state_update: bool = True

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.add_state("min", torch.tensor(float("inf")), persistent=True) # pylint: disable=not-callable
Expand Down
2 changes: 2 additions & 0 deletions anomalib/utils/metrics/optimal_f1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class OptimalF1(Metric):
predicted anomaly scores.
"""

full_state_update: bool = False

def __init__(self, num_classes: int, **kwargs):
super().__init__(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ opencv-python>=4.5.3.56
pandas>=1.1.0
pytorch-lightning>=1.6.0,<1.7.0
timm==0.5.4
torchmetrics>=0.9.0,<=0.9.1
torchmetrics>=0.9.1,<=0.9.3
torchvision>=0.9.1,<=0.12.0
torchtext>=0.9.1,<=0.12.0
wandb==0.12.17

0 comments on commit 36ac8cd

Please sign in to comment.