Skip to content

Commit

Permalink
Deprecate OptimalF1 metric (#796)
Browse files Browse the repository at this point in the history
* deprecate OptimalF1 metric

* update changelog
  • Loading branch information
djdameln authored Dec 16, 2022
1 parent 32c2d19 commit 4a6c4ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- 📊 Update DFM results (<https://github.com/openvinotoolkit/anomalib/pull/674>)
- Optimize anomaly score calculation for PatchCore (<https://github.com/openvinotoolkit/anomalib/pull/633>)

### Deprecated

- Deprecate OptimalF1 metric in favor of AnomalyScoreThreshold and F1Score (<https://github.com/openvinotoolkit/anomalib/pull/796>)

### Fixed

- Fix PatchCore performance deterioration by reverting changes to Average Pooling layer (<https://github.com/openvinotoolkit/anomalib/pull/791>)
Expand Down
9 changes: 9 additions & 0 deletions anomalib/utils/metrics/optimal_f1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import warnings

import torch
from torchmetrics import Metric, PrecisionRecallCurve

Expand All @@ -17,6 +19,13 @@ class OptimalF1(Metric):
full_state_update: bool = False

def __init__(self, num_classes: int, **kwargs):
warnings.warn(
DeprecationWarning(
"OptimalF1 metric is deprecated and will be removed in a future release. The optimal F1 score for "
"Anomalib predictions can be obtained by computing the adaptive threshold with the "
"AnomalyScoreThreshold metric and setting the computed threshold value in TorchMetrics F1Score metric."
)
)
super().__init__(**kwargs)

self.precision_recall_curve = PrecisionRecallCurve(num_classes=num_classes)
Expand Down

0 comments on commit 4a6c4ba

Please sign in to comment.