Spatial Autoregressive Modeling of DINOv3 Embeddings for Unsupervised Anomaly Detection

Ertunc Erdil, Nico Schulthess, Guney Tombak, Ender KonukogluarXiv 2026

TL;DR

This paper introduces a lightweight, fast, and memory-efficient framework for Unsupervised Anomaly Detection (UAD) by explicitly modeling the spatial dependencies of DINOv3 patch embeddings using a 2D autoregressive CNN. By replacing bulky memory banks and complex transformer decoders with a parametric autoregressive model, the approach achieves state-of-the-art anomaly detection performance with a single forward pass, drastically reducing inference time and memory overhead.

What Problem Does This Paper Address?

Unsupervised Anomaly Detection (UAD) is crucial in fields like medical imaging (e.g., spotting lesions) and industrial inspection (e.g., finding structural defects), where anomalous training data is rare or expensive to label. Recently, self-supervised foundation models like DINO have become popular because their patch-level embeddings capture rich semantic information.

However, existing DINO-based anomaly detection methods suffer from two major flaws:

  1. Ignoring Spatial Relationships: They typically treat patch embeddings as independent samples, assuming that DINO's internal self-attention mechanism already captures enough context. This ignores the structured 2D layout of the image grid.
  2. Heavy Computational Overhead: To define what "normal" looks like, current methods often rely on massive memory banks (storing all healthy training features) or complex prototype clustering. At test time, this requires expensive nearest-neighbor searches, making them too slow and memory-intensive for resource-constrained clinical or industrial deployments.

Methods

The authors propose a lightweight, CNN-based 2D autoregressive (AR) model to capture the joint spatial distribution of DINOv3 embeddings across an image grid.

Instead of sequential processing (which is notoriously slow for autoregressive models), they enforce the AR constraint using masked convolutions (similar to PixelCNN). This allows the entire grid to be processed in parallel during both training and inference.

Fig. 1: Illustration of (a) raster-scan autoregressive factorization over the embed- ding grid where the blue cell indicates the current prediction target, green cells denote preceding (conditioned) embeddings, and red cells correspond to future spatial locations which are treated as unobserved to predict the blue embedding, (b) Standard and masked convolutional kernels without dilation, and (c) corre- sponding dilated convolutional kernels. Grey cells indicate masked weights that prevent access to future spatial positions.

Key components of the architecture include:

  • Autoregressive Factorization: The model predicts the probability of a patch embedding based only on the patches that preceded it in a top-left to bottom-right raster scan.
  • von Mises-Fisher (vMF) Distribution: Because normalized DINO features are highly expressive, the conditional distribution of the patches is modeled using a vMF distribution, which effectively translates the training objective into minimizing cosine loss.
  • Dilated Convolutions: Because DINO features are already globally contextualized, neighboring patches are highly correlated. A standard CNN tends to cheat by simply interpolating from immediate neighbors, which hurts its ability to spot large anomalies. Introducing dilated convolutions expands the receptive field, forcing the model to learn wider contextual dependencies.

At test time, the anomaly score for each patch is simply its negative log-likelihood. A single forward pass yields the entire anomaly map.

Datasets

The method was evaluated on two primary benchmarks:

  1. BMAD (Benchmark for Medical Anomaly Detection): Consisting of three subsets:
  2. BraTS2021: 2D brain MRI slices (8,179 normal, 3,119 anomalous).
  3. BTCV + LiTs: Liver CT datasets (2,468 normal, 733 anomalous).
  4. RESC: Retinal OCT images (5,383 normal, 834 anomalous).
  5. VisA Dataset: An industrial anomaly detection dataset containing 12 object categories.

Key Insights and Ideas

  • The Local Interpolation Trap: The authors discovered that standard AR models overfit to local patterns because DINO features are highly correlated over short distances. Dilated convolutions act as a regularizer against this short-range "cheating," significantly boosting performance on datasets with large anomalies like brain tumors.
  • Embedding Space vs. Pixel Space: While pixel-space autoregressive models often fail at out-of-distribution detection because they get distracted by low-level noise and image statistics, applying AR modeling to semantic embedding space (DINO features) bypasses this issue entirely, focusing the model on high-level structural anomalies.

Key Results

The proposed method delivers a massive win for computational efficiency while maintaining or exceeding state-of-the-art accuracy:

  • Accuracy: On the BraTS2021 dataset, the dilated AR variant achieved the highest overall Area Under the Precision-Recall curve (73.88% AUPR), outperforming the previous best DINO baseline (AnomalyDINO v3-S) by 4.39 percentage points.
  • Speedup: On the RESC dataset, the standard convolution variant required only 14 ms per image, compared to 585 ms for AnomalyDINO v3-S—a ~41x speedup.
  • Memory Reduction: Peak memory consumption during inference plummeted to just 0.2 GB, compared to 11.3 GB for AnomalyDINO v3-S and 5.0 GB for PatchCore.

Limitations and Future Work

  • 2D vs. 3D Context: The model currently processes medical images slice-by-slice (2D). Incorporating volumetric (3D) context would likely improve performance, particularly on challenging datasets like liver CTs where foreground-background imbalance is severe.
  • Dataset Bias: The BMAD benchmark treats unannotated volume slices as completely "normal," which underrepresents certain healthy anatomy and introduces bias.
  • Configuration Tuning: Determining whether a dataset will benefit more from standard vs. dilated convolutions or causal vs. bidirectional modeling currently requires empirical testing; a more unified selection strategy is left for future work.

Summary updated

Abstract

DINO models provide rich patch-level representations that have recently enabled strong performance in unsupervised anomaly detection (UAD). Most existing methods extract patch embeddings from normal images and model them independently, ignoring spatial and neighborhood relationships between patches. This implicitly assumes that self-attention and positional encodings sufficiently encode contextual information within each patch embedding. In addition, the normative distribution is often modeled as memory banks or prototype-based representations, which require storing large numbers of features and performing costly comparisons at inference time, leading to substantial memory and computational overhead. In this work, we explicitly model spatial and contextual dependencies between patch embeddings using a 2D autoregressive (AR) model, allowing us to use a simple and efficient model for normative modeling. Instead of storing embeddings or clustering prototypes, our approach learns a compact parametric model of the normative distribution via an AR convolutional neural network (CNN). At test time, anomaly detection reduces to a single forward pass through the network and enables fast and memory-efficient inference. We evaluate our method on the BMAD benchmark, comprising three medical imaging datasets, and the VisA dataset, comprising 12 industrial object categories, and compare it against existing methods, including recent DINO-based approaches. Experimental results demonstrate that explicitly modeling spatial dependencies achieves competitive anomaly detection performance while substantially reducing inference time and memory requirements. Code is available at the project page: https://eerdil.github.io/spatial-ar-dinov3-uad/
BibTeX
@misc{erdil2026spatial,
  author = {Ertunc Erdil and Nico Schulthess and Guney Tombak and Ender Konukoglu},
  title = {{Spatial Autoregressive Modeling of DINOv3 Embeddings for Unsupervised Anomaly Detection}},
  year = {2026},
  eprint = {2603.02974},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.02974},
}

Loading related content...

Figure