Anomalib image_threshold with recall=1 #2800
-
in anomalib PaDiM, model.image_threshold = 88.8 for the best F1 score. using just pred_scores that are between 0 and 1, and labels the threshold that I am getting is 0.4 (value between 0 and 1) but manually I found the threshold that makes the recall = 1 and maximaizes the precision is 77.8 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Each model in anomalib generates a prediction by using the So in your case, instead of calculating the threshold based on F1 (this is done internally by using F1AdaptiveThreshold), you could: Turn off post-processing from anomalib.models import Padim
model = Padim(post_processor=False) This would generate an "anomaly map" which you can do any custom normalisation, thresholding or processing you want. Change PostProcessor Args The PostProcessor has some args you can change. As an example you could keep the normalisation of the from anomalib.models import Padim
from anomalib.post_processing import PostProcessor
post_processor = PostProcessor(enable_thresholding=False)
model = Padim(post_processor=post_processor) Then you could manually set the threshold but keep the normalisation that anomalib does. Create your own Implement a new adaptive threshold I think this is probably the best way for longevity is to create your own Instead of This could adaptively set the threshold for optimal Recall whilst maintaining anomalibs |
Beta Was this translation helpful? Give feedback.
-
Thanks @alfieroddan for the detailed response. I'm converting this to a Q&A. We could continue there if needed |
Beta Was this translation helpful? Give feedback.
Each model in anomalib generates a prediction by using the
PostProcessor
.So in your case, instead of calculating the threshold based on F1 (this is done internally by using F1AdaptiveThreshold), you could:
Turn off post-processing
This would generate an "anomaly map" which you can do any custom normalisation, thresholding or processing you want.
Change PostProcessor Args
The PostProcessor has some args you can change.
As an example you could keep the normalisation of the
PostProcessor
but turn off the thresholding.