Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No

About

Out-of-distribution (OOD) detection refers to training the model on an in-distribution (ID) dataset to classify whether the input images come from unknown classes. Considerable effort has been invested in designing various OOD detection methods based on either convolutional neural networks or transformers. However, zero-shot OOD detection methods driven by CLIP, which only require class names for ID, have received less attention. This paper presents a novel method, namely CLIP saying no (CLIPN), which empowers the logic of saying no within CLIP. Our key motivation is to equip CLIP with the capability of distinguishing OOD and ID samples using positive-semantic prompts and negation-semantic prompts. Specifically, we design a novel learnable no prompt and a no text encoder to capture negation semantics within images. Subsequently, we introduce two loss functions: the image-text binary-opposite loss and the text semantic-opposite loss, which we use to teach CLIPN to associate images with no prompts, thereby enabling it to identify unknown samples. Furthermore, we propose two threshold-free inference algorithms to perform OOD detection by utilizing negation semantics from no prompts and the text encoder. Experimental results on 9 benchmark datasets (3 ID datasets and 6 OOD datasets) for the OOD detection task demonstrate that CLIPN, based on ViT-B-16, outperforms 7 well-used algorithms by at least 2.34% and 11.64% in terms of AUROC and FPR95 for zero-shot OOD detection on ImageNet-1K. Our CLIPN can serve as a solid foundation for effectively leveraging CLIP in downstream OOD tasks. The code is available on https://github.com/xmed-lab/CLIPN.

Hualiang Wang, Yi Li, Huifeng Yao, Xiaomeng Li• 2023

Related benchmarks

TaskDatasetResultRank
Out-of-Distribution DetectionTextures
AUROC0.8863
141
OOD DetectionPlaces (OOD)
AUROC87.45
76
OOD DetectionSUN (OOD)
AUROC91.17
72
OOD DetectionImageNet-1K OOD (Average: OpenImage-O, Texture, iNaturalist, ImageNet-O) 1.0 (test)
AUROC93.1
61
Out-of-Distribution DetectionImageNet-1k Textures ID OOD
AUROC90.93
59
Out-of-Distribution DetectionImageNet-1k (ID) with 4 OOD datasets (iNaturalist, SUN, Places, Textures)
FPR9531.1
45
Open Domain GeneralizationOfficeHome
Acc84.55
43
OOD DetectionImageNet SUN
FPR@9526.17
43
OOD DetectioniNaturalist
AUROC88.03
40
Domain GeneralizationDigits-DG
Accuracy81.7
38
Showing 10 of 42 rows

Other info

Follow for update