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

🚨Hotfix: compute precision recall on raw scores #1973

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/anomalib/metrics/optimal_f1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import torch
from torchmetrics import Metric
from torchmetrics.classification import BinaryPrecisionRecallCurve

from anomalib.metrics.precision_recall_curve import BinaryPrecisionRecallCurve

logger = logging.getLogger(__name__)

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/metrics/test_optimal_f1.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ def test_optimal_f1_raw() -> None:

metric.update(preds, labels)
assert metric.compute() == 1.0
assert metric.threshold == 0.5
assert metric.threshold == 0.0

metric.reset()
preds = torch.tensor([-0.5, 0.0, 1.0, 2.0, -0.1])
metric.update(preds, labels)
assert metric.compute() == torch.tensor(1.0)
assert metric.threshold == -0.1
Loading