deel-ai / oodeel

Simple, compact, and hackable post-hoc deep OOD detection for already trained tensorflow or pytorch image classifiers.
https://deel-ai.github.io/oodeel/
MIT License
52 stars 2 forks source link

SCALE + ASH methods #88

Open paulnovello opened 7 months ago

paulnovello commented 7 months ago

Implements both ASH and SCALE baselines at the same time because they are very similar.

SCALE method

SCALE method basically consists of re-using existing logit-based OOD methods, but with penultimate layer activations scaled. Let $a$ be the activation vector, and $Pp(a)$ the $p$-th percentile of $a$'s values. The scaling is computed using the formula $s = \exp(\frac{\sum{i} ai}{\sum{a_i > P_p(a)} a_i})$

Here, we focus on a Resnet trained on CIFAR10, challenged on SVHN.

Reference
Scaling for Training Time and Post-hoc Out-of-distribution Detection Enhancement, ICLR 2024 https://arxiv.org/abs/2111.12797

ASH method

This notebook aims at evaluating the ASH method.

ASH method basically consists of re-using existing logit-based OOD methods, but with penultimate layer activations scaled and pruned. Let $a$ be the activation vector, and $P_p(a)$ the $p$-th percentile of $a$'s values. The scaling is computed using the same formula as above. The activation vector is pruned for values $a_i \leq P_p(a)$.

Here, we focus on a Resnet trained on CIFAR10, challenged on SVHN.

Reference
Extremely Simple Activation Shaping for Out-of-Distribution Detection, ICLR 2023 http://arxiv.org/abs/2209.09858

github-actions[bot] commented 6 months ago

β˜‚οΈ Python Coverage

current status: βœ…

Overall Coverage

Lines Covered Coverage Threshold Status
2390 2213 93% 70% 🟒

New Files

No new covered files...

Modified Files

File Coverage Status
oodeel/extractor/feature_extractor.py 94% 🟒
oodeel/extractor/keras_feature_extractor.py 97% 🟒
oodeel/extractor/torch_feature_extractor.py 99% 🟒
oodeel/methods/base.py 83% 🟒
oodeel/methods/energy.py 100% 🟒
oodeel/methods/entropy.py 100% 🟒
oodeel/methods/gen.py 96% 🟒
oodeel/methods/mls.py 100% 🟒
oodeel/methods/odin.py 100% 🟒
TOTAL 96% 🟒

updated for commit: 26ee9fb by action🐍