How Many Categories Are Enough? Distribution-Free Certification Limits for Few-Shot Anomaly Thresholds
Authors: Gia Huy Thai, Nguyen Thai Anh
Organizations: University of Science, VNU-HCM, Ho Chi Minh City, Vietnam · Faculty of Information Technology, Van Lang School of Technology, Van Lang University, Ho Chi Minh City, Vietnam
Few-shot anomaly detectors are judged by ranking metrics, yet deployment requires an alarm threshold with a controlled false-alarm rate (FAR). We ask how much normal evidence, in images or category units, is needed to certify such a threshold for an unseen category. Using a frozen DINOv2 principal component analysis (PCA) residual ranker on 15 MVTec and 12 VisA categories under four corruption types, we show that target-only leave-one-image-out (LOIO) calibration is resolution-limited and shift-fragile: rank values cannot fall below 1/(k+1), and at the attainable level α=0.20, empirical FAR reaches 0.341 on Gaussian-corrupted MVTec at k=4, 1.7 times the nominal level. A category-count feasibility calculus is then derived: even with all-zero category losses and no multiplicity charged, any deterministic, uniformly valid, distribution-free 95% upper confidence bound (UCB) requires at least 14, 29, and 59 independent and identically distributed (iid) category draws at α=0.20, 0.10, and 0.05; these counts are necessary but not sufficient. The Cross-category Reliability Estimation with Source Support (CRESS) protocol splits source categories into disjoint reference, proposal, and certification roles. With only three or four certification categories, all 960 frozen configurations return the fail-closed threshold τ⋆=0, and the smallest category-level UCB is 0.950. Image-unit analyses of the same archive select positive thresholds in 36.7% to 60.3% of target cells; these bounds hold for the selected source mixture, not for the marginal risk of a new-category draw. The contribution is a quantitative feasibility boundary and an estimand-aware protocol specifying when source evidence can, and cannot, support a transferable reliability claim.
Figures & tables
Figure 1: Analytic category-count feasibility after observing zero loss in every certification category. The black curve is the multiplicity-free lower bound 1−0.051/n for deterministic uniformly valid distribution-free procedures in Proposition 3. The blue curve applies the frozen allocation β=δ/(2AM) with δ=0.05 , A=3 reported levels, and the favorable one-candidate case M=1 ; the orange curve is the corresponding Hoeffding floor. Horizontal lines mark the requested risk levels, and the shaded region marks the three or four distinct certification categories available in the frozen audit; interpreting them as iid units is a modeling assumption. The black circular crossings at the 14, 29, and 59 axis ticks mark optimistic necessary counts without multiplicity, not sufficient sample sizes for CRESS. A curve above a requested α rules out a positive threshold only within its stated procedure class, even under all-zero observed category loss.
Figure 2: Target-side scoring and reliability routes. Panel (a) employs frozen DINOv2 patch features and a support-fitted PCA residual scorer to produce the fixed image-ranking score and, optionally, a pixel anomaly map. The metric boxes are used exclusively for evaluation; the pixel map is an inherited output and does not serve as a certification target or a localization claim within this study. Panel (b) applies the scorer within LOIO folds to generate target-normal calibration scores and the target-only rank value pc,LOIO(x) . Since calibration scores utilize k−1 supports and the test score uses all k , this rank transformation is subject to empirical auditing rather than being assumed to possess automatic finite-sample validity. The minimum attainable value is 1/(k+1) , and the alarm rule does not modify the underlying ranking score.
Figure 3: CRESS source-side threshold certification. Each non-target source category provides normal support images for scorer fitting and support-only normalization statistics, along with held-out known-normal views under specified audit conditions. During source-archive preparation, scores are normalized before source-view selection. When k=1 , the declared patch-split support residual replaces LOIO calibration. Eligible source categories are partitioned into disjoint reference ( R ), proposal ( P ), and certification ( C ) roles. The reference set establishes the source-reference map pR , which is then applied to proposal and certification views. The proposal set determines the candidate family, while the certification set generates category losses for the family-adjusted risk UCB. CRESS returns either the largest passing threshold or the fail-closed value zero. This process yields a source-domain certificate; however, target-category control requires the transfer condition specified in Corollary 1.
rule / candidates
α=.20
α=.10
α=.05
Distribution-free, no multiplicity
14
29
59
Distribution-free, M=1
22
46
94
Distribution-free, M=5
29
61
125
Distribution-free, M=20
35
74
152
Hoeffding, M=1
60
240
958
Hoeffding, M=5
80
320
1,280
Table 1: The minimum iid certification-category counts required by the all-zero calculations at δ=0.05 . The distribution-free rows indicate the necessary lower bounds for deterministic, uniformly valid procedures as described in Proposition 3, first without multiplicity ( β=δ ), and then with β=δ/(2AM) , A=3 , and realized family size M . The ’Hoeffding’ row corresponds to Proposition 2. All rows assume zero observed loss; satisfying a listed count does not guarantee a positive CRESS threshold.
dataset
k
floor
nominal α
attainable
FAR
power
VisA (full)
4
0.200
0.01
0.000
0.000
0.000
0.05
0.000
0.000
0.000
0.10
0.000
0.000
0.000
0.20
0.200
0.142
0.595
8
0.111
0.01
0.000
0.000
0.000
0.05
0.000
0.000
0.000
Table 2: Target-only LOIO operating points. The floor represents the smallest rank value, 1/(k+1) , while the term ’attainable’ refers to the largest rank-value grid point not exceeding the nominal α , or zero if no such point exists. For each corruption, FAR and detection power are pooled across categories and seeds. The table subsequently averages the four corruption-specific rates.
dataset
corruption
k
FAR
power
precision
VisA (full)
blur
4
0.144
0.606
0.825
8
0.094
0.566
0.870
bright/contr.
4
0.146
0.596
0.821
8
0.098
0.557
0.864
Gaussian noise
4
0.133
0.575
0.829
8
0.081
0.538
0.881
Table 3: Target-only LOIO FAR, detection power, and alarm precision at the first reported attainable level, α=0.20 . The results utilize five support-sampling seeds with support sets nested across k , and are pooled over images within each dataset, corruption, and k . All normal and anomalous test images are retained. Alarms are triggered when the rank value satisfies p≤α , following the comparison tolerance specified in the text.
Figure 4: Empirical CDF of normal-image LOIO rank values at each attainable point j/(k+1) , compared to the tie-free discrete-uniform benchmark (dashed diagonal), using five support-sampling seeds. Valid ties may cause the population CDF to fall below this benchmark. Points above the diagonal indicate an excess of empirical false alarms relative to the benchmark. The lower-right insets and connector rays provide an enlarged view of the first attainable grid region.
source → target
certification unit
units/cell
min UCB
nonzero frac.
interpretation
MVTec → MVTec
category
4
0.950
0.000
category-unit gate fails
VisA → VisA
category
3
1.000
0.000
category-unit gate fails
MVTec → VisA
category
4
0.961
0.000
category-unit gate fails
MVTec → MPDD
category
4
0.986
0.000
category-unit gate fails
MVTec → MVTec
source image
75 to 191
0.039
0.367
iid-image sensitivity
VisA → VisA
source image
150 to 180
0.042
0.603
iid-image sensitivity
Table 4: Frozen strict CRESS audit over 960 job × source-view ×k×α× condition configurations, 240 per source-to-target job. Each configuration includes 75 MVTec, 60 VisA, or 30 MPDD target-category/seed cells; thus, the ’nonzero frac.’ metric aggregates 18,000, 14,400, or 7,200 cells per respective job. ’Min UCB’ denotes the smallest observed candidate bound. Category and image rows address distinct estimands; image rows operate under the idealized iid source-image model.
source → target
α
FAR
power
MVTec → MVTec
0.05
0.075
0.404
0.10
0.131
0.566
0.20
0.242
0.754
VisA → VisA
0.05
0.060
0.320
0.10
0.111
0.466
0.20
0.208
0.639
Table 5: Direct pooled-source conformal under matched-condition selection. Reported entries represent unweighted means of within-target-cell rates across categories, k∈{1,2,4,8} , five support seeds, and five conditions. The complete selected source pool applies τ=α without a reference/proposal/certification split; this is an empirical, uncertified baseline.
Dataset
k
Method
AUROC ↑
AP ↑
MiB ↓
MVTec
1
AnomalyDINO-S (reported)
0.965
0.981
–
WinCLIP (reported)
0.931
N/C
N/R
Controlled DINOv2 NN
0.914
0.952
2.005
PCA64 (controlled)
0.904
0.951
0.095
4
AnomalyDINO-S (reported)
0.976
0.984
–
WinCLIP (reported)
0.952
N/C
N/R
Table 6: Clean image-level ranking performance and category-specific ranker state in mebibytes (MiB). The controlled DINOv2 NN and PCA64/PCA128 methods utilize a shared feature set, data split, evaluation metric, and storage-accounting protocol, with results averaged over categories and five random seeds. AnomalyDINO-S (448) and WinCLIP values are reported in [ 7 , 16 ] under their respective protocols. Bold marks the best value only among common-protocol rows within each dataset/ k block. The notation ’–’ indicates not evaluated, N/C denotes not directly comparable, and N/R signifies not reported.
dataset
k
max
top-0.5%
top-1%
top-2%
top-5%
MVTec
4
0.9571
0.9638
0.9667
0.9693
0.9621
8
0.9578
0.9685
0.9740
0.9759
0.9727
VisA
4
0.9039
0.9101
0.9038
0.8944
0.8806
8
0.9101
0.9200
0.9147
0.9071
0.8941
Table 7: Aggregation-sensitivity ablation for clean image AUROC under max and top- ρ mean pooling. Results average three MVTec categories (bottle, cable, and hazelnut) or four VisA categories (candle, cashew, pcb1, and pipe fryum) over seeds from 0 to 2. Bold marks the best tested aggregator in each row. This subset analysis diagnoses sensitivity within the displayed grid; it is not a full-dataset ranking comparison.