Skip to content
Discussion options

You must be logged in to vote

Hi @Cua1103,
This is because the Accuracy class from torchmetrics uses new() instead of init() to create an object.

I suggest using a more specific torchmetrics accuracy class. It looks like you want to use binary classification metric with AnomalibMetric

from torchmetrics.classification.accuracy import BinaryAccuracy
from anomalib.metrics import AnomalibMetric

class AnomalibBinaryAccuracy(AnomalibMetric, BinaryAccuracy):
    pass

binary_accuracy = AnomalibBinaryAccuracy(
    fields=["pred_label", "gt_label"],
)

Can also be used with create_anomalib_metric

from torchmetrics.classification.accuracy import BinaryAccuracy
from anomalib.metrics import create_anomalib_metric

binary_accurac…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by samet-akcay
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2678 on April 29, 2025 16:11.