arXiv:2608.23295cs.CVAug 2026

Manuscript Offprint

arXiv:2608.23295

What Memory Composition Does Not Tell Us About Anomaly Detection

Joongwon Chae, Runming Wang, Peiwu Qin

ABSTRACT

Memory-based anomaly detectors store nominal training patches and score test patches against this memory. A patch selected for coverage therefore becomes a normal reference without a separate check that geometric rarity makes it safe to trust. We probe this coupling with sparse training contamination. Under fixed representations and memory budgets, we compare random, medoid, local, and global coverage selectors. We then use CLEANCON, an out-of-bag cross-image support gate that changes candidate-image eligibility while fixing the representation, absolute memory size, builder, and inference rule. Global coverage strongly over-represents sparse contamination. CLEANCON reduces final-memory contamination to approximately zero and increases category-macro P-AP in all 12 matched comparisons. Yet along a retention sweep, the lowest-contamination memory does not attain the highest P-AP; performance continues to improve while contamination rises. Memory contamination therefore does not order the resulting memories by P-AP.Code is publicly available at https://github.com/jw-chae/cleancon.

1 INTRODUCTION

Memory-based industrial anomaly detection extracts patch features from nominal training images, stores a compact subset in memory, and identifies anomalies through discrepancies between test patches and the stored features (Cohen & Hoshen, 2021; Defard et al., 2021; Roth et al., 2022). In this family, memory is not merely a compressed training set. Selected patches remain direct normal references at inference time.

PatchCore constructs this memory with an approximate-greedy coreset that seeks broad feature-space coverage (Roth et al., 2022). The sensitivity of coverage objectives to outliers is well known in the literature on k-center and robust clustering (Charikar et al., 2001; Friedler & Mount, 2010; Krishnaswamy et al., 2018). In memory-based anomaly detection, however, this sensitivity has a more direct consequence. A selected center does not disappear into a subsequent optimizer; it remains in the deployed detector as a normal reference.

Sparse contamination provides a simple probe of this coupling (Fig. 1). If a small number of anomalous images enter the nominal training pool, rare patches within them can be attractive to a global coreset. We ask two questions. How strong is this selection bias in the final memory? And does reducing the resulting contaminated references improve the detector?

We compare random sampling, medoid selection, local approximate-greedy farthest-first selection (Local FF), and global farthest-first selection (Global FF) under identical representations and budgets. CLEANCON then ranks each training image by an out-of-bag cross-image projection residual and passes only low-scoring images to the original builder. It changes candidate-image eligibility while fixing the representation, absolute memory size, builder, and inference rule.

Global FF draws substantially more contaminated patches into memory. CLEANCON reduces final-memory contamination to approximately zero and increases category-macro P-AP in all 12 matched comparisons. Yet along the retention sweep, the lowest-contamination memory does not attain the

(a)

Figure

one selection, two roles

(b)

Figure

candidate-image eligibility changes

(c)

Figure

cleanest ≠ best

Figure 1: One selection, two roles. (a) Selected patches serve global coverage and test-time normal evidence. (b) Candidate-image eligibility changes while the absolute memory size and detector remain fixed. (c) The lowest-contamination memory is not necessarily the best-performing one.

highest P-AP, and performance continues to improve as contamination rises. Cleaning helps, but purity alone does not order useful memories.

Our main findings are:

• Global coverage strongly over-represents sparse contamination. Random, medoid, and Local FF controls place the strongest effect under Global FF competition across images.

• CLEANCON reduces contamination and raises matched macro P-AP. With all downstream components and bank sizes fixed, final-memory contamination approaches zero and category-macro P-AP rises in all 12 comparisons.

• The cleanest memory is not the best memory. Along the retention sweep, contamination and P-AP repeatedly rise together.