git clone https://github.com/xmed-lab/CLIPN.git
cd CLIPN
conda create -n CLIPN
conda activate CLIPN
pip install -r ./requirements.txt
When you have downloaded CC3M, please re-write your data root into ./src/run.sh.
When you have downloaded the above datasets, please re-write your data root into ./src/tuning_util.py.
Pre-train CLIPN on CC3M. This step is to empower "no" logic within CLIP via the web-dataset.
cd ./src
sh run.sh
Zero-Shot Evaluate CLIPN on ImageNet-1K.
python3 zero_shot_infer.py
To ensure the reproducibility of the results, we conducted three repeated experiments under each configuration. The following will exhibit the most recent reproduced results achieved before open-sourcing.
Methods | Repeat | iNaturalist | SUN | Textures | Places | Avg | Model/log | |||||
AUROC | FPR95 | AUROC | FPR95 | AUROC | FPR95 | AUROC | FPR95 | AUROC | FPR95 | |||
ViT-B-16 | ||||||||||||
CLIPN-CTW | 1 | 93.12 | 26.31 | 88.46 | 37.67 | 79.17 | 57.14 | 86.14 | 43.33 | _ | _ | here |
2 | 93.48 | 21.06 | 89.79 | 30.31 | 83.31 | 46.44 | 88.21 | 33..85 | _ | _ | here | |
3 | 91.79 | 25.84 | 89.76 | 31.30 | 76.76 | 59.25 | 87.66 | 36.58 | _ | _ | here | |
Avg | 92.80 | 24.41 | 89.34 | 33.09 | 79.75 | 54.28 | 87.34 | 37.92 | 87.31 | 37.42 | _ | |
CLIPN-ATD | 1 | 95.65 | 21.73 | 93.22 | 29.51 | 90.35 | 42.89 | 91.25 | 36.98 | _ | _ | here |
2 | 96.67 | 16.71 | 94.77 | 23.41 | 92.46 | 34.73 | 93.39 | 29.24 | _ | _ | here | |
3 | 96.29 | 18.90 | 94.55 | 24.15 | 89.61 | 45.12 | 93.23 | 30.11 | _ | _ | here | |
Avg | 96.20 | 19.11 | 94.18 | 25.69 | 90.81 | 40.91 | 92.62 | 32.11 | 93.45 | 29.46 | _ |
The performance in this table is better than our paper , because that we add an average learnable "no" prompt (see Line 600-616 in ./src/open_clip/model.py).
There are several important factors that could affect the performance:
If you find our paper helps you, please kindly consider citing our paper in your publications.
@inproceedings{wang2023clipn,
title={CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No},
author={Wang, Hualiang and Li, Yi and Yao, Huifeng and Li, Xiaomeng},
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
pages={1802--1812},
year={2023}
}
We sincerely appreciate these three highly valuable repositories open_clip, MOS and MCM.