This repository release the official codes of our works on out-of-distribution detection with Vision-Language Models. We also reproduce some representative methods for reference.
The code is well organized, therefore you can easily develop new algorithms by modifying ONLY ONE python file!!
-
20 Mar, 2026: TANL is accepted by CVPR 2026, you can easily reproduce our results with Bash
-
20 Mar, 2026: ANTS is accepted by CVPR 2026 (Oral), you can easily reproduce our results with Bash
-
21 Nov, 2024: AdaNeg is accepted by NeurIPS 2024, you can easily reproduce our results with Bash
-
23 Aug, 2024: LAPT is accepted by ECCV 2024, you can easily reproduce our results with Bash and Checkpoint
Follow OpenOOD to set up the environment, or use our provided instructions below.
pip install git+https://github.com/YBZH/OpenOOD-VLM
We also follow OpenOOD to manage the training and testing datasets. If you only use our evaluator, the benchmarks for evaluation will be automatically downloaded by the evaluator (again check out this tutorial). If you would like to also use OpenOOD-VLM for training, you can get all data with our downloading script. Note that ImageNet-1K training images should be downloaded from its official website.
Besides datasets used in OpenOOD, we also provide evaluation on some popular OOD datasets iNaturalist, SUN, Places, and Texture curated by Huang et al. 2021. Please follow instruction from the this repository to download the subsampled datasets where semantically overlapped classes with ImageNet-1k are removed.
Our codebase accesses the datasets from ./data/ and pretrained models from ./results/checkpoints/ by default.
├── ...
├── data
│ ├── benchmark_imglist
│ ├── images_classic
│ └── images_largescale
├── openood
├── results
│ ├── checkpoints
│ └── ...
├── scripts
├── main.py
├── ...
Supported Datasets for Out-of-Distribution Detection
- BIMCV (A COVID X-Ray Dataset)
Near-OOD:
CT-SCAN,X-Ray-Bone;
Far-OOD:MNIST,CIFAR-10,Texture,Tiny-ImageNet;- MNIST
Near-OOD:
NotMNIST,FashionMNIST;
Far-OOD:Texture,CIFAR-10,TinyImageNet,Places365;- CIFAR-10
Near-OOD:
CIFAR-100,TinyImageNet;
Far-OOD:MNIST,SVHN,Texture,Places365;- CIFAR-100
Near-OOD:
CIFAR-10,TinyImageNet;
Far-OOD:MNIST,SVHN,Texture,Places365;- ImageNet-200
Near-OOD:
SSB-hard,NINCO;
Far-OOD:iNaturalist,Texture,OpenImage-O;
Covariate-Shifted ID:ImageNet-C,ImageNet-R,ImageNet-v2;- ImageNet-1K
Near-OOD:
SSB-hard,NINCO;
Far-OOD:iNaturalist,Texture,OpenImage-O;
Covariate-Shifted ID:ImageNet-C,ImageNet-R,ImageNet-v2;- ImageNet-1K Traditional Four Datasets
Far-OOD:
iNaturalist,SUN,Places,Texture;
Covariate-Shifted ID:ImageNet-C,ImageNet-R,ImageNet-v2;
We provide training and evaluation scripts for all the methods we support in scripts folder.
- [
CVPR2026 Official] TANL
sh scripts/ood/TANL/official.sh- [
CVPR2026 Official] ANTS
sh scripts/ood/ants/imagenet.sh- [
NeurIPS Official] AdaNeg
sh scripts/ood/adaneg/imagenet.sh
sh scripts/ood/adaneg/plus_LAPT.sh # Apply AdaNeg to the pre-trained LAPT prompt- [
ECCV2024 Official] LAPT with pre-trained Checkpoint
sh scripts/ood/lapt/test.sh- [
NIPS2022 Reproduced] Zero-shot MCM
sh scripts/ood/mcm/official.sh- [
ICLR2024 Reproduced] Zero-shot NegLabel
sh scripts/ood/neglabel/official.shIf you find our repository useful for your research, please consider citing our paper:
@article{zhang2026activation,
title={Activation Matters: Test-time Activated Negative Labels for OOD Detection with Vision-Language Models},
author={Zhang, Yabin and Varma, Maya and Gao, Yunhe and Delbrouck, Jean-Benoit and Liu, Jiaming and Wang, Chong and Langlotz, Curtis},
journal={IEEE/CVF conference on computer vision and pattern recognition},
year={2026}
}
@article{zhu2025ants,
title={ANTS: Adaptive Negative Textual Space Shaping for OOD Detection via Test-Time MLLM Understanding and Reasoning},
author={Zhu, Wenjie and Zhang, Yabin and Jin, Xin and Zeng, Wenjun and Zhang, Lei},
journal={IEEE/CVF conference on computer vision and pattern recognition},
year={2026}
}
@article{zhang2024adaneg,
title={Adaneg: Adaptive negative proxy guided ood detection with vision-language models},
author={Zhang, Yabin and Zhang, Lei},
journal={Advances in Neural Information Processing Systems},
volume={37},
pages={38744--38768},
year={2024}
}
@inproceedings{zhang2024lapt,
title={Lapt: Label-driven automated prompt tuning for ood detection with vision-language models},
author={Zhang, Yabin and Zhu, Wenjie and He, Chenhang and Zhang, Lei},
booktitle={European conference on computer vision},
pages={271--288},
year={2024},
organization={Springer}
}
@inproceedings{zhu2025knowledge,
title={Knowledge Regularized Negative Feature Tuning of Vision-Language Models for Out-of-Distribution Detection},
author={Zhu, Wenjie and Zhang, Yabin and Jin, Xin and Zeng, Wenjun and Zhang, Lei},
booktitle={Proceedings of the 33rd ACM International Conference on Multimedia},
pages={3565--3574},
year={2025}
}- OpenOOD, an extensible codebase with Vision Models only.