Improving and Assessing Anomaly Detectors for Large-Scale Settings

1 INTRODUCTION . Out-of-distribution ( OOD ) detection is a valuable tool for developing safe and reliable machine learning ( ML ) systems . Detecting anomalous inputs allows systems to initiate a conservative fallback policy or defer to human judgment . As an important component of ML Safety ( Hendrycks et al. , 2021 ) , OOD detection is important for safety-critical applications such as self-driving cars and detecting novel microorganisms . Accordingly , research on out-of-distribution detection has a rich history spanning several decades ( Schölkopf et al. , 1999 ; Breunig et al. , 2000 ; Emmott et al. , 2015 ) . Recent work leverages deep neural representations for out-of-distribution detection in complex domains , such as image data ( Hendrycks & Gimpel , 2017 ; Lee et al. , 2018a ; Mohseni et al. , 2020 ; Hendrycks et al. , 2019b ) . However , these works still primarily use small-scale datasets with low-resolution images and few classes . As the community moves towards more realistic , large-scale settings , strong baselines and high-quality benchmarks are imperative for future progress . Large-scale datasets such as ImageNet ( Deng et al. , 2009 ) and Places365 ( Zhou et al. , 2017 ) present unique challenges not seen in small-scale settings , such as a plethora of fine-grained object classes . We demonstrate that the maximum softmax probability ( MSP ) detector , a state-of-the-art method for small-scale problems , does not scale well to these challenging conditions . Through extensive experiments , we identify a detector based on the maximum logit ( MaxLogit ) that greatly outperforms the MSP and other strong baselines in large-scale multi-class anomaly segmentation . To facilitate further research in this setting , we also collect a new out-of-distribution test dataset suitable for models trained on highly diverse datasets . Shown in Figure 2 , our Species dataset contains diverse , anomalous species that do not overlap ImageNet-21K which has approximately twenty two thousand classes . Species avoids data leakage and enables a stricter evaluation methodology for ImageNet-21K models . Using Species to conduct more controlled experiments without train-test overlap , we find that contrary to prior claims ( Fort et al. , 2021 ; Koner et al. , 2021 ) , Vision Transformers ( Dosovitskiy et al. , 2021a ) pre-trained on ImageNet-21K are not substantially better at out-of-distribution detection . Moreover , in the common real-world case of multi-label data , the MSP detector can not naturally be applied in the first place , as it requires softmax probabilities . To enable research into the multi-label setting for anomaly detection , we contribute a multi-label experimental setup and explore various methods on large-scale multi-label datasets . We find that the MaxLogit detector from our investigation into the large-scale multi-class setting generalizes well to multi-label data and again outperforms all other baselines . In addition to focusing on small-scale datasets , most existing benchmarks for anomaly detection treat entire images as anomalies . In practice , an image could be anomalous in localized regions while being in-distribution elsewhere . Knowing which regions of an image are anomalous could allow for safer handling of unfamiliar objects in the case of self-driving cars . Creating a benchmark for this task is difficult , though , as simply cutting and pasting anomalous objects into images introduces various unnatural giveaway cues such as edge effects , mismatched orientation , and lighting , all of which trivialize the task of anomaly segmentation ( Blum et al. , 2019 ) . To overcome these issues , we utilize a simulated driving environment to create the novel StreetHazards dataset for anomaly segmentation . Using the Unreal Engine and the open-source CARLA simulation environment ( Dosovitskiy et al. , 2017 ) , we insert a diverse array of foreign objects into driving scenes and re-render the scenes with these novel objects . This enables integration of the foreign objects into their surrounding context with correct lighting and orientation , sidestepping giveaway cues . To complement the StreetHazards dataset , we convert the BDD100K semantic segmentation dataset ( Yu et al. , 2018 ) into an anomaly segmentation dataset , which we call BDD-Anomaly . By leveraging the large scale of BDD100K , we reserve infrequent object classes to be anomalies . We combine this dataset with StreetHazards to form the Combined Anomalous Object Segmentation ( CAOS ) benchmark . The CAOS benchmark improves over previous evaluations for anomaly segmentation in driving scenes by evaluating detectors on realistic and diverse anomalies . We evaluate several baselines on the CAOS benchmark and discuss problems with porting existing approaches from earlier formulations of out-of-distribution detection . Despite its simplicity , we find that the MaxLogit detector outperforms all baselines on Species , our multi-class benchmark , and CAOS . In each of these three settings , we discuss why MaxLogit provides superior performance , and we show that these gains are hidden if one looks at small-scale problems alone . The code for our experiments and the Species and CAOS datasets are available at [ anonymized ] . Our new baseline combined with Species and CAOS benchmarks pave the way for future research on large-scale out-of-distribution detection . 2 RELATED WORK . Multi-Class Out-of-Distribution Detection . A recent line of work leverages deep neural representations from multi-class classifiers to perform out-of-distribution ( OOD ) detection on highdimensional data , including images , text , and speech data . Hendrycks & Gimpel ( 2017 ) formulate the task and propose the simple baseline of using the maximum softmax probability of the classifier on an input to gauge whether the input is out-of-distribution . In particular , they formulate the task as distinguishing between examples from an in-distribution dataset and various OOD datasets . Importantly , entire images are treated as out-of-distribution . Continuing this line of work , Lee et al . ( 2018a ) propose to improve the neural representation of the classifier to better separate OOD examples . They use generative adversarial networks to produce neardistribution examples and induce uniform posteriors on these synthetic OOD examples . Hendrycks et al . ( 2019b ) observe that outliers are often easy to obtain in large quantity from diverse , realistic datasets and demonstrate that OOD detectors trained on these outliers generalize to unseen classes of anomalies . Other work investigates improving the anomaly detectors themselves given a fixed classifier ( DeVries & Taylor , 2018 ; Liang et al. , 2018 ) . However , as Hendrycks et al . ( 2019b ) observe , many of these works tune hyperparameters on a particular type of anomaly that is also seen at test time , so their evaluation setting is more lenient . In this paper , all anomalies seen at test time come from entirely unseen categories and are not tuned on in any way . Hence , we do not compare to techniques such as ODIN ( Liang et al. , 2018 ) . Additionally , in a point of departure from prior work , we focus primarily on large-scale images and datasets with many classes . Recent work has suggested that stronger representations from Vision Transformers pre-trained on ImageNet-21K can make out-of-distribution detection trivial ( Fort et al. , 2021 ; Koner et al. , 2021 ) . They evaluate models on detecting CIFAR-10 when fine-tuned on CIFAR-100 or vice versa , using models pretrained on ImageNet-21K . However , over 1,000 classes in ImageNet-21K overlap with CIFAR-10 , so it is still unclear how Vision Transformers perform at detecting entirely unseen OOD categories . We create a new OOD test dataset of anomalous species to investigate how well Vision Transformers perform in controlled OOD detection settings without data leakage and overlap . We find that Vision Transformers pre-trained on ImageNet-21K are far from solving OOD detection in large-scale settings . Anomaly Segmentation . Several prior works explore segmenting anomalous image regions . One line of work uses the WildDash dataset ( Zendel et al. , 2018 ) , which contains numerous annotated driving scenes in conditions such as snow , fog , and rain . The WildDash test set contains fifteen “ negative images ” from different domains for which the goal is to mark the entire image as out-ofdistribution . Thus , while the task is segmentation , the anomalies do not exist as objects within an otherwise in-distribution scene . This setting is similar to that explored by Hendrycks & Gimpel ( 2017 ) , in which whole images from other datasets serve as out-of-distribution examples . To approach anomaly segmentation on WildDash , Krešo et al . ( 2018 ) train on multiple semantic segmentation domains and treat regions of images from the WildDash driving dataset as out-ofdistribution if they are segmented as regions from different domains , i.e . indoor classes . Bevandić et al . ( 2018 ) use ILSVRC 2012 images and train their network to segment the entirety of these images as out-of-distribution . In medical anomaly segmentation and product fault detection , anomalies are regions of otherwise in-distribution images . Baur et al . ( 2019 ) segment anomalous regions in brain MRIs using pixelwise reconstruction loss . Similarly , Haselmann et al . ( 2018 ) perform product fault detection using pixel-wise reconstruction loss and introduce an expansive dataset for segmentation of product faults . In these relatively simple domains , reconstruction-based approaches work well . In contrast to medical anomaly segmentation and fault detection , we consider complex images from street scenes . These images have high variability in scene layout and lighting , and hence are less amenable to reconstruction-based techniques . The two works closest to our own are the Lost and Found ( Pinggera et al. , 2016 ) and Fishyscapes ( Blum et al. , 2019 ) datasets . The Lost and Found dataset consists of real images in a driving environment with small road hazards . The images were collected to mirror the Cityscapes dataset ( Cordts et al. , 2016 ) but are only collected from one city and so have less diversity . The dataset contains 35 unique anomalous objects , and methods are allowed to train on many of these . For Lost and Found , only nine unique objects are truly unseen at test time . Crucially , this is a different evaluation setting from our own , where anomalous objects are not revealed at training time , so their dataset is not directly comparable . Nevertheless , the BDD-Anomaly dataset fills several gaps in Lost and Found . First , the images are more diverse , because they are sourced from a more recent and comprehensive semantic segmentation dataset . Second , the anomalies are not restricted to small , sparse road hazards . Concretely , anomalous regions in Lost and Found take up 0.11 % of the image on average , whereas anomalous regions in the BDD-Anomaly dataset are larger and fill 0.83 % of the image on average . Finally , although the BDD-Anomaly dataset treats three categories as anomalous , compared to Lost and Found it has far more unique anomalous objects . The Fishyscapes benchmark for anomaly segmentation consists of cut-and-paste anomalies from out-of-distribution domains . This is problematic , because the anomalies stand out as clearly unnatural in context . For instance , the orientation of anomalous objects is unnatural , and the lighting of the cut-and-paste patch differs from the lighting in the original image , providing an unnatural cue to anomaly detectors that would not exist for real anomalies . Figure 7 shows an example of these inconsistencies . Techniques for detecting image manipulation ( Zhou et al. , 2018 ; Johnson & Farid , 2005 ) are competent at detecting artificial image elements of this kind . Our StreetHazards dataset overcomes these issues by leveraging a simulated driving environment to naturally insert anomalous 3D models into a scene rather than overlaying 2D images . These anomalies are integrated into the scene with proper lighting and orientation , mimicking real-world anomalies and making them significantly more difficult to detect .

Summary: The authors extend the out-of-distribution (OOD) detection from not-seen in small-scale settings to large-scale multiclass and multi-label ones. They provide large-scale benchmarks for evaluating ODD detectors on classification as well as segmentation. Additionally, they propose a simple yet strong baseline for this practical problem.