-
Notifications
You must be signed in to change notification settings - Fork 653
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
[Bug]: anomaly map normalization in efficient ad looks wrong #1370
Comments
Hey!
Yes you're right about that. Fixing this isn't too easy in anomalib I guess, so the question is how this is affecting the model performance and if it is a real problem. Of course you shouldn't show the model anything of the validation set during training, but for this kind of normalization the model might not learn to much information from the validation data.
I don't get this completely. Why shouldn't it be designed this way? Using the tqdm in the model however seems fine to me, as long as its not in the forward function of the torch model (that is used for inference in the end)
Thats right, however the original paper also only uses a subset of 60k imagenet images.. |
I corrected that on my fork (will open the PR soon).
I think lightning's design is made essentially to avoid loops on the batches. By implementing In the current design, there is a for loop in the start
which is re-doing this structure, while
The 60k you refer to is from here, right? (appendix A.2, algorithm 3, page 16) Well, using the imagenet1k (1k classes, 1.2M images), would be quite more diverse then this subset of only 10 classes, but, yes, effect to be tested. The paper's ablation suggests a somewhat important effect This is one of the things I changed and will be rolling back to see the effect. |
I adressed A and C in #1376 |
Describe the bug
Poiting out a few things:
A) normalization params should depend on a split from the train set
The default YAML config is using a random split from the test set
anomalib/src/anomalib/models/efficient_ad/config.yaml
Line 18 in c97762c
which is usual for models that only do evaluation on the val set, but in efficientad
(from http://arxiv.org/abs/2303.14535, Section 3.4, page 6, left column)
☝️ the validation set is like a 2nd-phase (or 3rd counting the distillation) of the training, where$q^{\text{ST}}_a, q^{\text{ST}}_b, q^{\text{AE}}_a, q^{\text{AE}}_b$ are fitted.
It should be possible to split the train set and use it there.
B) validation start/step design is weird
I think lightning's design is made essentially to avoid loops on the batches.$q$ parameters. In the current design, there is a for loop in the start
By implementing validation_step(batch) you define what the model should do with that data -- which, for EfficientAD, is to find the
anomalib/src/anomalib/models/efficient_ad/lightning_model.py
Lines 245 to 252 in c97762c
function
map_norm_quantiles()
anomalib/src/anomalib/models/efficient_ad/lightning_model.py
Lines 154 to 179 in c97762c
which is re-doing this loop-over-batches structure, while
validation_step()
is just predicting (which would happen in the test_step() or predict_step()):anomalib/src/anomalib/models/efficient_ad/lightning_model.py
Lines 253 to 266 in c97762c
C) small imagenet
The data used in the penalty term of the student's loss function should be the same as the one from the teacher distillation (imagenet in the paper).
The code is currently downloading a reduced version with 10 classes.
The user should be able to use a custom folder (with imagenet already setup).
Code of Conduct
The text was updated successfully, but these errors were encountered: