anomalib icon indicating copy to clipboard operation
anomalib copied to clipboard

pixel metrics calculation process bugs

Open MacavityT opened this issue 2 years ago • 3 comments

Once I tried to get pixel metrics like "precision" and "recall", so I set the config in .yaml file as following:

metrics:
  image:
    - F1Score
    - AUROC
  pixel:
    - Precision
    - F1Score
    - Recall
  threshold:
    image_default: 3
    pixel_default: 15
    adaptive: false

But finally I got just "precision" value while the "f1 score" and "recall" as 0.0000

So I changed the code in anomalib/utils/metrics/collection.py as following:

    def update(self, *args, **kwargs) -> None:
        """Add data to the metrics."""
    
        # super().update(*args, **kwargs)  # remove this line
        # my addition
        for metric in self.values():
            if callable(getattr(metric, 'update')):
                getattr(metric, 'update')(*args, **kwargs)
        ###

        self._update_called = True

Then I got correct results.

MacavityT avatar Jul 05 '22 07:07 MacavityT

Are you using the latest changes from the development branch? Just adding Precision to the config.yaml works when I try it. Here are my changes image

ashwinvaidya17 avatar Jul 05 '22 07:07 ashwinvaidya17

Hi @MacavityT, can you provide the details of your system. Hardware, software. When I try this on my system with the default settings, it works as well. Here is my configuration;

image

And here is the results image

samet-akcay avatar Jul 11 '22 13:07 samet-akcay

@samet-akcay I also met this problem on my machine. I want to add metrics as A、P、R to code, but A、P、R always got value 0.0 or 1.0 in the log. Was this a bug?How can I solve it?

metrics:
image:
- F1Score
- AUROC
- Accuracy
- Precision
- Recall
pixel:
- F1Score
- AUROC
threshold:
image_default: 0
pixel_default: 0
adaptive: true

My machine's setting is Windows 10 home Chinese--AMD Ryzen 5 4600H--anomalib Version0.3.3.

loyal-ikun avatar Jul 16 '22 04:07 loyal-ikun

I am closing this as this is not reproducible in the current version on Anomalib.

ashwinvaidya17 avatar Sep 19 '22 11:09 ashwinvaidya17