Home

Awesome

T2FNorm: Train-time Feature Normalization for OOD Detection in Image Classification

This codebase provides a Pytorch implementation of:

T2FNorm: Train-time Feature Normalization for OOD Detection in Image Classification.
t2fnorm
Sudarshan Regmi, Bibek Panthi, Sakar Dotel, Prashnna K. Gyawali, Danail Stoyanov, Binod Bhattarai

Abstract

Neural networks are notorious for being overconfident predictors, posing a significant challenge to their safe deployment in real-world applications. While feature normalization has garnered considerable attention within the deep learning literature, current train-time regularization methods for Out-of-Distribution(OOD) detection are yet to fully exploit this potential. Indeed, the naive incorporation of feature normalization within neural networks does not guarantee substantial improvement in OOD detection performance. In this work, we introduce T2FNorm, a novel approach to transforming features to hyperspherical space during training, while employing non-transformed space for OOD-scoring purposes. This method yields a surprising enhancement in OOD detection capabilities without compromising model accuracy in in-distribution(ID). Our investigation demonstrates that the proposed technique substantially diminishes the norm of the features of all samples, more so in the case of out-of-distribution samples, thereby addressing the prevalent concern of overconfidence in neural networks. The proposed method also significantly improves various post-hoc OOD detection methods.

T2FNorm highlights in OpenOODv1.5 leaderboard [Updated: June 2024]

ranks 4th in the far-OOD AUROC metric on CIFAR10 datasets.
ranks 8th in the far-OOD AUROC metric on CIFAR100 datasets.
ranks 9th in the far-OOD AUROC metric on ImageNet200 datasets (OOD).
ranks 5th in the far-OOD AUROC metric on ImageNet200 datasets (FSOOD).

<p style="display: flex; align-items: center;"> <span>Check other works:</span>&nbsp;&nbsp;&nbsp; <a href="https://github.com/sudarshanregmi/reweightood"><img src="https://img.shields.io/badge/CVPRW'24-ReweightOOD-f4d5b3?style=for-the-badge" alt="reweightood" style="margin-right: 10px;"></a> </p>

Follow OpenOOD official instruction to complete the setup.

pip install git+https://github.com/Jingkang50/OpenOOD

T2FNorm Illustration

<p align="center"> <img width="800" src="T2FNorm.png"> </p>

Example Scripts for Training and Inference

Use the following scripts for training and inferencing the model trained with T2FNorm regularization on different datasets:

Pre-trained checkpoints

Pre-trained models are available in the given links:

The inference scripts for T2FNorm currently utilize the T2FNorm postprocessor (MSP with scaled feature). However, T2FNorm is compatible with various types of postprocessors.

Results

datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
cifar10030.60 ± 0.4591.56 ± 0.1092.31 ± 0.0690.20 ± 0.1694.69 ± 0.07
tin22.33 ± 0.3794.02 ± 0.1695.47 ± 0.1191.91 ± 0.2894.69 ± 0.07
nearood26.47 ± 0.3592.79 ± 0.1393.89 ± 0.0891.06 ± 0.2294.69 ± 0.07
mnist3.50 ± 1.3399.28 ± 0.2797.01 ± 1.0299.89 ± 0.0494.69 ± 0.07
svhn5.72 ± 0.6698.81 ± 0.2297.47 ± 0.3699.54 ± 0.1094.69 ± 0.07
texture19.49 ± 2.5895.44 ± 0.7797.17 ± 0.4992.85 ± 1.2394.69 ± 0.07
places36522.27 ± 1.2894.40 ± 0.3287.48 ± 0.7698.17 ± 0.1094.69 ± 0.07
farood12.75 ± 0.7396.98 ± 0.2394.79 ± 0.2297.61 ± 0.3394.69 ± 0.07
datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
cifar1067.07 ± 1.9076.09 ± 0.8176.13 ± 1.0473.38 ± 0.8076.43 ± 0.13
tin49.88 ± 0.8583.59 ± 0.0288.82 ± 0.0474.02 ± 0.2776.43 ± 0.13
nearood58.47 ± 1.3579.84 ± 0.4082.48 ± 0.5373.70 ± 0.4076.43 ± 0.13
mnist39.39 ± 5.3886.22 ± 2.2968.13 ± 4.3797.13 ± 0.4776.43 ± 0.13
svhn44.29 ± 3.1486.04 ± 1.0476.98 ± 1.8992.87 ± 0.5176.43 ± 0.13
texture66.82 ± 4.6177.32 ± 1.6384.54 ± 1.5264.15 ± 1.8376.43 ± 0.13
places36554.50 ± 0.5281.35 ± 0.3364.83 ± 0.6692.41 ± 0.1376.43 ± 0.13
farood51.25 ± 2.5282.73 ± 1.0173.62 ± 1.5786.64 ± 0.6276.43 ± 0.13
datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
ssb_hard65.94 ± 0.2779.00 ± 0.1645.76 ± 0.4594.26 ± 0.0586.87 ± 0.19
ninco44.09 ± 0.7986.99 ± 0.0291.74 ± 0.0779.03 ± 0.1986.87 ± 0.19
nearood55.01 ± 0.3683.00 ± 0.0768.75 ± 0.2586.64 ± 0.1086.87 ± 0.19
inaturalist13.47 ± 0.7696.87 ± 0.1397.09 ± 0.1496.82 ± 0.1086.87 ± 0.19
textures33.46 ± 0.3491.95 ± 0.2094.43 ± 0.1887.57 ± 0.3686.87 ± 0.19
openimage_o29.17 ± 0.6991.81 ± 0.1989.31 ± 0.2494.21 ± 0.1486.87 ± 0.19
farood25.37 ± 0.5593.55 ± 0.1793.61 ± 0.1892.87 ± 0.2086.87 ± 0.19
datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
ssb_hard89.35 ± 0.0946.13 ± 0.3649.11 ± 0.2548.42 ± 0.2645.00 ± 0.23
ninco80.45 ± 0.3857.63 ± 0.1391.82 ± 0.0614.00 ± 0.0945.00 ± 0.23
nearood84.90 ± 0.1751.88 ± 0.2370.47 ± 0.1431.21 ± 0.1645.00 ± 0.23
inaturalist55.99 ± 1.2882.36 ± 0.2595.24 ± 0.1150.99 ± 1.0745.00 ± 0.23
textures74.81 ± 0.3871.22 ± 0.3594.99 ± 0.0925.00 ± 1.3745.00 ± 0.23
openimage_o72.07 ± 0.5167.02 ± 0.3985.90 ± 0.2039.56 ± 0.1045.00 ± 0.23
farood67.62 ± 0.7073.53 ± 0.3092.04 ± 0.1338.51 ± 0.8245.00 ± 0.23
datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
ssb_hard81.6865.9164.8665.1576.76
ninco56.680.2596.931.8376.76
nearood69.1473.0880.8848.4976.76
inaturalist20.6594.8798.880.676.76
textures38.2290.5398.6160.4676.76
openimage_o34.8690.3596.4375.0176.76
farood31.2491.9297.9572.0276.76
datasetsFPR@95AUROCAUPR_INAUPR_OUTACC
ssb_hard89.2847.9968.7530.4955.27
ninco73.161.7496.776.9855.27
nearood81.1954.8682.7618.7355.27
inaturalist44.1283.2597.9928.2755.27
textures59.7577.1998.3614.455.27
openimage_o57.175.1295.1726.1555.27
farood53.6678.5297.1822.9455.27

Please consider citing our work if you find it useful.

@InProceedings{Regmi_2024_CVPR_2,
    author    = {Regmi, Sudarshan and Panthi, Bibek and Dotel, Sakar and Gyawali, Prashnna K and Stoyanov, Danail and Bhattarai, Binod},
    title     = {T2FNorm: Train-time Feature Normalization for OOD Detection in Image Classification},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
    month     = {June},
    year      = {2024},
    pages     = {153-162}
}

Acknowledgment

This codebase builds upon OpenOOD.