openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
https://anomalib.readthedocs.io/en/latest/
Apache License 2.0
3.65k stars 647 forks source link

[Bug]: Wrong normalization used for some models. #1813

Open blaz-r opened 6 months ago

blaz-r commented 6 months ago

Describe the bug

Some of the models have wrong normalization setup in current version of code. This list includes: DSR, DRAEM, EfficientAD, and rkde.

All of the above methods shouldn't use imagenet normalization, but they have the default method setup (which uses imagenet normaliztion): https://github.com/openvinotoolkit/anomalib/blob/9482d34049dad874fcf68edbc79454638700813a/src/anomalib/models/components/base/anomaly_module.py#L224-L241 or in case of the EfficientAD it is manually set to imagenet: https://github.com/openvinotoolkit/anomalib/blob/9482d34049dad874fcf68edbc79454638700813a/src/anomalib/models/image/efficient_ad/lightning_model.py#L311-L319

Dataset

Other (please specify in the text field below)

Model

Other (please specify in the field below)

Steps to reproduce the behavior

/

OS information

/

Expected behavior

All of the above (and potentially some other models, but I think those are the only four) should have normalization set to just get all the images to [0, 1] range.

Screenshots

No response

Pip/GitHub

GitHub

What version/branch did you use?

main

Configuration YAML

/

Logs

/

Code of Conduct

youngquan commented 1 month ago

Does using imagenet normalization affect the results much? Did you do any experiments? When I used draem, the anomaly maps rendered poorly. The anomalous regions are not rendered red. I'm still trying to figure out why.

blaz-r commented 1 month ago

Draem must not use imagenet normalization because the synthetic anomalies are in range 0-1, therefore images need to be normalized to 0-1 as well.