Memory-Bounded Continuation of Greedy Sampling for Continual Anomaly Detection

1Northeastern University  2AIVEX  3Mitsubishi Electric Research Laboratories
BMVC 2026

*Equal Contribution
ContCore pipeline

ContCore keeps a fixed-size coreset across tasks. Greedy expansion adds the new-task features that are maximally distant from the current coreset (green); greedy consolidation removes the redundant ones (red) to hold the memory budget.

Abstract

Greedy sampling produces a compact yet representative summary of normal data, which is essential for reliable anomaly detection that relies on measuring distance from normality. For continual anomaly detection where tasks arrive sequentially, extending greedy sampling is straightforward with unbounded memory through coreset accumulation. However, practical deployment requires fixed memory where the coreset size remains constant regardless of task count. We observe that continued greedy sampling, which iteratively applies greedy selection over previously greedy-sampled sets, effectively preserves representativeness under strict memory limits. Despite discarding data at each step to satisfy the memory constraint, coreset quality degrades gracefully rather than catastrophically, enabling reliable anomaly detection across the tasks. We provide theoretical justification by showing that the resulting greedy-continued coreset approximates the oracle coreset within a bounded gap. We instantiate this principle in ContCore, which constructs a greedy-continued coreset through greedy expansion followed by greedy consolidation to enforce the memory budget. Unlike neural methods susceptible to catastrophic forgetting or naive coreset accumulation requiring unbounded memory, ContCore maintains fixed memory with theoretical guarantees. Empirically, ContCore achieves state-of-the-art performance across 11 task schedules on MVTecAD and VisA, and extends effectively to online continual AD settings where prior methods degrade significantly.

Why continual anomaly detection is hard

Unsupervised anomaly detection scores a test sample by how far it lies from a model of normality, so the quality of that model decides everything. In deployment, new product classes keep arriving — without labels, and usually without any way to revisit the data from earlier tasks.

Naively adapting a network to each new task causes catastrophic forgetting. Dedicated continual AD methods do not remove that problem so much as move it around:

  • Memory-based methods (DNE, UCAD) survive long schedules but break on complex multi-class tasks.
  • Regularization-based methods (IUF, CDAD) handle complex tasks but forget over long schedules — and are expensive to train.

Coreset-based AD sidesteps forgetting entirely: there is no network to overwrite, so a new task is simply new features added to memory. The catch is that memory then grows with the number of tasks $T$, while real deployment fixes a budget $m$.

The question this paper answers: can a coreset held at a fixed size $m$ preserve the representativeness of the unbounded one?

Task-average AUROC as classes accumulate

Baselines degrade as classes accumulate on MVTecAD; ContCore stays flat on both the $1\times15$ and $10-1\times5$ schedules.


Method

1. Greedy sampling on a base set

Greedy sampling $\Gcal_n$ repeatedly collects the point that is maximally distant from everything selected so far, producing a compact yet representative coreset. We extend it with a base set $B$, so that a candidate is compared against both the sampled set and $B$:

\[ \Gcal_n(\Zcal; B) = \Bigl\{\, z_i^{*} \in \Zcal \;:\; z_i^{*} = \arg\max_{z \in \Zcal} \, d\bigl(z,\; \Zcal_{i-1}^{*} \cup B\bigr) \Bigr\} \]

The base set is arbitrary, and $B = \emptyset$ recovers the original greedy sampling. This is the hinge of the whole method: making $B$ the current coreset is what lets greedy sampling generalize across tasks.


2. Greedy-continued coreset

At task $t$, ContCore updates the fixed-size memory $\Mcal_t$ in two nested steps:

\[ \Mcal_t \;=\; \Gcal_{m}\bigl(\Gcal_{n_t}(\Zcal_t;\, \Mcal_{t-1}) \,\cup\, \Mcal_{t-1}\bigr) \]

  • Greedy expansion $\Gcal_{n_t}(\cdot\,;\Mcal_{t-1})$ — samples $n_t$ features from the new task that are maximally distant from the current coreset, so only features that genuinely add coverage enter memory.
  • Greedy consolidation $\Gcal_{m}(\cdot)$ — keeps $m$ maximally separated features of the combined set, enforcing the budget while preserving coverage.

Note what is not in this update: no network weights, no replay buffer, and no task identifier at inference. The memory is the model, so memory, compute and inference latency are all constant in the number of tasks.

ContCore pipeline

3. In practice

  • Approximation for speed. Consolidation is the expensive step. After expansion the combined features are already mostly representative, so instead of a full greedy pass we rank a fraction $q$ of the embeddings by nearest-neighbour distance $d_i = d\!\left(z_i,\, \widehat{\Mcal}_t \setminus \{z_i\}\right)$ and take those with the largest distances directly. Quality holds up to $q = 0.75$ while sampling time drops by roughly half.
  • Inference follows PatchCore. A patch embedding $z^{(h,w)}$ is scored by $a^{(h,w)} = d\!\left(z^{(h,w)},\, \Mcal_t\right)$, and the image score is the maximum over patches. Nothing is re-trained at any point — there is no gradient step across tasks, so there is nothing to forget.

4. Theory: a bounded gap to the oracle coreset

Theorem 4.1. Let $H$ be the Hausdorff distance, $\Ocal = \Gcal_{n_0}(\cup_{t=1}^{T}\Zcal_t)$ the oracle coreset — greedy sampling run over all task data at once — and $\Mcal_T$ the greedy-continued coreset after $T$ tasks. Suppose $H(\Ocal, \cup_{t=1}^{T}\Zcal_t) \le \varepsilon_o$, $H(S_t, \Zcal_t) \le \varepsilon_t$ and $H(\Mcal_t, S_t \cup \Mcal_{t-1}) \le \widehat{\varepsilon}_t$. Then

\[ H(\Ocal,\, \Mcal_T) \;\le\; \varepsilon_o \;+\; \max_{1 \le k \le T}\left( \varepsilon_k + \sum_{j=k}^{T} \widehat{\varepsilon}_j \right) \]

The structure of the second term is the point. The error accumulates per task but does not compound — it is a maximum over sums of per-task quantities, not a product. That is why coreset quality degrades gracefully instead of collapsing, and with a sufficient per-task sampling size $n_t$ the greedy-continued coreset keeps its quality for any $T$.

Empirical tightness of the bound

Empirical tightness of Eq. (6) on MVTecAD. The measured $H(\Ocal, \Mcal_T)$ stays around 4.3–4.9 while the right-hand side grows from 6.65 to 19.04 — the bound holds with room to spare at every $T$.


Results

We evaluate on MVTecAD and VisA over 11 continual task schedules (MVTecAD: $1\times15$, $3\times5$, $10-1\times5$, $10-5$, $14-1$; VisA: $1\times12$, $8-1\times4$, $8-4$, $11-1$), plus cross-dataset transfer and online CAD. Features come from WideResNet50 (layers 2–3), with sampling ratio $p = 0.01$ and coreset size $m = 20{,}000$ on MVTecAD / $40{,}000$ on VisA, on a single RTX 3090. We report task-average image / pixel AUROC ($\uparrow$) and the forgetting measure FM ($\downarrow$).

MVTecAD results

Task average AUROC and FM on MVTecAD across 5 task schedules.

ContCore is the best method on every MVTecAD schedule (97.7–98.9 image AUROC), with forgetting at or near zero — because nothing is trained across tasks, there is nothing to forget.

VisA results

Task average AUROC and FM on VisA across 4 task schedules.

The same conclusion on VisA — best or tied-best on all four schedules (93.7–96.3 image AUROC). Consistency across all 11 schedules is the claim here, not a single peak number.


Efficiency

Efficiency comparison
Efficiency table
9.24 GFLOPs vs 5628 for CDAD; 754 s of training vs 281k s for CDAD and 39k s for IUF; 39 ms inference, roughly 70× faster than CDAD. No trade is being made — the cheapest method here is also the most accurate, because there is no diffusion model and no per-task SVD projection, just feature extraction and a distance query.


Cross-dataset transfer and online CAD

Cross-dataset results

Cross-dataset CAD: MVTec→VisA and VisA→MVTec.

Online CAD results

Online CAD: one pass over the data, batch size 1.

Cross-dataset, ContCore beats the strongest baseline by 4.3 points on MVTec→VisA and 8.9 points on VisA→MVTec. In the online setting — each sample seen exactly once, batch size 1 — the baselines collapse into the 58–84 range while ContCore holds 97.2 and 94.1. Greedy expansion always measures new features against the current coreset, so it can make a sensible keep-or-drop decision from a single sample.

Ablation & Analysis

Ablation results

Ablation on MVTecAD: coreset size $m$ (a), sampling ratio $p$ (b), approximate ratio $q$ (c), and sampling time against $q$ (d).

  • Coreset size $m$ is the capacity knob — performance rises with $m$ and plateaus past 20k, which is where we set it. Beyond that you pay inference time for nothing.
  • Sampling ratio $p$ barely matters between 0.01 and 0.5. Even if expansion pulls in redundant features, consolidation removes them — so we use the cheapest setting.
  • Approximate ratio $q$ is flat up to 0.75 and only collapses at $q = 1$, where pure nearest-neighbour ranking destroys the coverage structure. Meanwhile sampling time falls monotonically with $q$, so $q = 0.75$ buys roughly half the sampling time for free.

Is the coreset actually the right one?

Our claim is that we approximate, under a continual budget, the coreset PatchCore would have built from all features at once — so we measure the result directly against it rather than only reporting AUROC.

Coreset comparison
Against random sampling of the same size, the greedy-continued coreset has an order of magnitude more overlapping samples with the oracle, and lower average minimum, sliced Wasserstein and Hausdorff distances — it is genuinely closer to the oracle, not just accidentally good downstream. ContCore also matches a PatchCore-Oracle baseline that is given the task count in advance to divide the budget evenly, and beats it online.

Poster

BibTeX

        
@inproceedings{jung2026contcore,
  title     = {Memory-Bounded Continuation of Greedy Sampling for Continual Anomaly Detection},
  author    = {Yoon Gyo Jung and Jaewoo Park and Kuan-Chuan Peng and Seongdeok Bang and Octavia Camps},
  booktitle = {British Machine Vision Conference (BMVC)},
  year      = {2026}
}