You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in anomalib PaDiM, model.image_threshold = 88.8 for the best F1 score.
but I want the recall = 1 even if I lose a little bit in precision, so I want recall = 1 and maximise the precision.
how can I find that threshold?
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
I think this is probably the best way for longevity is to create your own PostProcessor with your own threshold selection. Internally for PaDiM the default PostProcessor is used.
Activity
alfieroddan commentedon Jun 30, 2025
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
PostProcessorbut turn off the thresholding.Then you could manually set the threshold but keep the normalisation that anomalib does.
Create your own
PostProcessorSee here in the docs
Implement a new adaptive threshold
I think this is probably the best way for longevity is to create your own
PostProcessorwith your own threshold selection. Internally for PaDiM the defaultPostProcessoris used.Instead of
F1AdaptiveThreshold, you could write your own!This could adaptively set the threshold for optimal Recall whilst maintaining anomalibs
PostProcessorfeatures.samet-akcay commentedon Jun 30, 2025
Thanks @alfieroddan for the detailed response. I'm converting this to a Q&A. We could continue there if needed