Abstract
Machine learning algorithms are increasingly provided as black-box cloud services or pre-trained models, without access to their training data. This motivates the problem of zero-shot out-of-distribution (OOD) detection. Concretely, we aim to detect OOD objects that do not belong to the classifier's label set but are erroneously classified as in-distribution (ID) objects. Our approach, RONIN, uses an off-the-shelf diffusion model to replace detected objects with inpainting. RONIN conditions the inpainting process with the predicted ID label, drawing the input object closer to the in-distribution domain. As a result, the reconstructed object is very close to the original in the ID cases and far in the OOD cases, allowing RONIN to effectively distinguish ID and OOD samples. Throughout extensive experiments, we demonstrate that RONIN achieves competitive results compared to previous approaches across several datasets, both in zero-shot and non-zero-shot settings.
Introduction
Modern object detectors are remarkably accurate but dangerously overconfident. When they encounter an object they’ve never seen before (an OOD object), they often force it into a known category (In-Distribution or ID) with high confidence. For example, a detector trained on farm animals might see a wild deer and confidently label it a "sheep." Existing solutions typically require retraining or access to OOD examples, which is impractical for many real-world deployments. RONIN (ZeRo-shot CONditional INpainting) addresses this by providing a post-hoc, zero-shot solution that can be integrated with any existing detector.
Methodology: The RONIN Framework
The core idea of RONIN is to leverage the fundamental difference between discriminative object detectors and generative image models. While a detector learns boundaries between classes, a generative model like Stable Diffusion learns the underlying distribution of what an object should look like.
The RONIN pipeline consists of three main stages:
- Detection: A standard detector identifies a bounding box and predicts a label (e.g., "dog").
- Class-Conditioned Inpainting: The system masks the detected object (covering about 80-90% of the box) and asks a generative model to "fill in the blanks" using the predicted label as a prompt. To improve efficiency, Class-wise Masking groups objects with the same predicted label into a single inpainting pass.
- Vision-Language Triplet Measurement: The system compares the original object, the inpainted version, and the text label using CLIP and SimCLRv2 embeddings. A "Triplet Score" determines if the original object and the inpainted version are semantically and visually consistent. High inconsistency indicates an OOD object.
Experimental Evaluation
RONIN was evaluated using Pascal-VOC and BDD-100k as ID datasets, with MS-COCO and OpenImages serving as OOD benchmarks.
Key Results
- Superior Accuracy: On the Pascal-VOC to MS-COCO task, RONIN achieved an AUROC of 92.31%, surpassing the best zero-shot baseline by over 2%.
- FPR Reduction: In the BDD-100k to OpenImages scenario, it achieved an FPR@95 of 23.33%, a significant improvement over discriminative baselines.
- Near-OOD Performance: By using "refined prompts" (e.g., explicitly instructing the model not to look like a zebra when inpainting a horse), RONIN reached an AUROC of 98.03% on challenging near-OOD cases.
Discussion and Insights
- Inconsistency as a Signal: If a detector is wrong, the generative model will "disagree" with the visual evidence. Telling a diffusion model to draw a "sheep" where a "deer" exists results in a reconstruction that deviates significantly from the original.
- Efficiency: The authors found that using as few as 5 denoising steps still provides a strong enough signal for detection, significantly reducing latency compared to standard generation.
- Contextual Robustness: By masking only the object and retaining the background, the generative model uses surrounding context to produce more accurate reconstructions for ID objects, sharpening the contrast for OOD samples.
Limitations and Future Work
While 5-step diffusion is efficient, it remains slower than a single forward pass of a detector, making it more suitable for safety-critical or offline applications. Additionally, small, poorly lit, or heavily occluded objects can lead to inpainting failures. Future work may leverage "one-step" generative models to enable real-time performance for robotics and autonomous driving.
Summary updated