  Detecting out-of-distribution (OOD) and adversarial samples is essential when
deploying classification models in real-world applications. We introduce
Channel Mean Discrepancy (CMD), a model-agnostic distance metric for evaluating
the statistics of features extracted by classification models, inspired by
integral probability metrics. CMD compares the feature statistics of incoming
samples against feature statistics estimated from previously seen training
samples with minimal overhead. We experimentally demonstrate that CMD magnitude
is significantly smaller for legitimate samples than for OOD and adversarial
samples. We propose a simple method to reliably differentiate between
legitimate samples from OOD and adversarial samples using CMD, requiring only a
single forward pass on a pre-trained classification model per sample. We
further demonstrate how to achieve single image detection by using a
lightweight model for channel sensitivity tuning, an improvement on other
statistical detection methods. Preliminary results show that our simple yet
effective method outperforms several state-of-the-art approaches to detecting
OOD and adversarial samples across various datasets and attack methods with
high efficiency and generalizability.
