  Deep neural networks are susceptible to generating overconfident yet
erroneous predictions when presented with data beyond known concepts. This
challenge underscores the importance of detecting out-of-distribution (OOD)
samples in the open world. In this work, we propose a novel feature-space OOD
detection score based on class-specific and class-agnostic information.
Specifically, the approach utilizes Whitened Linear Discriminant Analysis to
project features into two subspaces - the discriminative and residual subspaces
- for which the in-distribution (ID) classes are maximally separated and
closely clustered, respectively. The OOD score is then determined by combining
the deviation from the input data to the ID pattern in both subspaces. The
efficacy of our method, named WDiscOOD, is verified on the large-scale
ImageNet-1k benchmark, with six OOD datasets that cover a variety of
distribution shifts. WDiscOOD demonstrates superior performance on deep
classifiers with diverse backbone architectures, including CNN and vision
transformer. Furthermore, we also show that WDiscOOD more effectively detects
novel concepts in representation spaces trained with contrastive objectives,
including supervised contrastive loss and multi-modality contrastive loss.
