Pooling Toward the Abnormal: Normality-Referenced Downsampling for Micro-Defect Detection

Automated visual inspection is supposed to beat people at small defects. Human inspectors cannot reliably find flaws below about 100 microns, while line-scan cameras resolve 5-micron scratches (Smart-Inspect). That advantage is usually thrown away in software. Frames that large must be shrunk to fit a network's memory and compute budget, and every pooling step averages a few defect pixels into a large patch of normal background. The strongest unsupervised detectors are one-class models, which learn only from defect-free parts and flag anything that looks unfamiliar. One common form of these is the "hypersphere" detector: it trains a network to map normal data close to a fixed center point and scores a test input by its distance from that center. These detectors inherit the same averaging problem. So do the standard fixes. Learnable pooling (LIP) and channel reweighting blocks (Squeeze-and-Excitation) learn what to emphasize from labels. A one-class model has no defect labels, so these modules have nothing to learn from.

This note proposes a simple change. When a one-class detector downsamples, the pooling weights and the channel weights should come from how far each fine-scale location deviates from the model of normality, and should not be learned freely from the input. In plain terms, the network carries its "is this abnormal?" question down through the resolution pyramid. When it shrinks a 4×4 window to one cell, the most abnormal location in the window dominates the result. The deeper, context-rich layers therefore still see a 5-pixel scratch, and they can judge it in context, for example scratch versus dust. Because the weights are tied to distances from a fixed center rather than to free parameters, the design also avoids the collapse failure that makes standard attention blocks unsafe in hypersphere training.

Core Claim

The claim has three parts. In one-class detection under a fixed resolution budget, small-defect recall is lost mainly at the downsampling steps. Input-driven attention cannot recover that recall, because it is trained without anomalies. Pooling that is weighted by local distance to normality can recover it, at essentially the cost of average pooling.

Concretely, at a downsampling stage with fine features $x_p$ at locations $p$ inside a pooling window $W$, a small head $\psi_\ell$ is trained one-class toward a fixed nonzero center $c_\ell$. This head is a 1×1 convolution with no bias. Pooling then uses

$$y = \sum_{p \in W} w_p \, x_p, \qquad w_p = \frac{\exp(d_p/\tau)}{\sum_{q \in W} \exp(d_q/\tau)}, \qquad d_p = \|\psi_\ell(x_p) - c_\ell\|,$$

where $\tau$ is a temperature. The limit $\tau \to \infty$ recovers the average pooling used in FPSVDD. The limit $\tau \to 0$ selects the single most abnormal location. The weights sum to one, so the pooled feature cannot shrink toward the center.

The channel side follows the same rule and replaces the global-average "squeeze" of Squeeze-and-Excitation. Each channel $k$ receives a gate proportional to its largest standardized deviation inside the window, $\max_{p\in W} |x_{pk}-\mu_k|/\sigma_k$. Here $\mu_k$ and $\sigma_k$ are normal-data statistics estimated once. The gates are renormalized to average one across channels. This removes the dilution problem of the global squeeze: a 5×5 defect in a 256×256 map contributes under 0.04% of the global mean but dominates a local maximum. It also removes the additive biases that Deep SAD identifies as a route to collapse.

Relation to Prior Work

Two hypersphere methods for industrial inspection motivate the proposal. Patch SVDD moved from one embedding per image to patch-level embeddings with self-supervised training and nearest-neighbor scoring. FPSVDD aggregates pretrained feature patches with adaptive average pooling before a Deep SVDD head. Both show that locality matters. Both also downsample uniformly, which is exactly the operation we replace.

Two papers supply mechanisms, and we change both. LIP learns importance maps for pooling and improves small-object detection on COCO (small-object precision from 21.9% to 24.0%), but its importance logits are trained with supervised losses. SE-ResNet18 for ACCC X-ray shows that channel reweighting raises recall on subtle "Splitting" defects from 88.2% to 94.0%, but only in closed-set supervised classification. We keep their idea of content-dependent weighting. We derive the weights from distance to normality, which is the only signal a one-class model actually has.

DO2HSC constrains the design. It shows that high-dimensional normal data concentrates in a thin shell and forms stretched, ellipsoid-shaped clouds rather than round ones. This is why our channel gate standardizes by the normal $\sigma_k$ instead of using raw magnitudes. DO2HSC was never tested on pixel-level industrial data, so its shell boundary is an optional final scoring head for us, not the contribution.

Reverse Distillation is the method to beat. It fuses multiple scales and compresses them through a bottleneck trained only on normal data, but it fuses with fixed strided convolutions. FRE is the strongest cheap competitor: it reconstructs frozen features with linear PCA at more than 30 frames per second on a CPU.

Research Program

The backbone is a frozen ImageNet-pretrained ResNet, as in FPSVDD and FRE, so that only the aggregation path is new. The aggregation path takes early high-resolution features down to the coarse grid of a deeper layer and then feeds a bias-free patch hypersphere head. We build four variants of this path that differ only in the downsampling rule. The first is average pooling, which reproduces FPSVDD. The second is max pooling. The third is a LIP-style module with free logits trained under the one-class loss. The fourth is our normality-referenced pooling plus channel gating.

The fine-scale heads $\psi_\ell$ train jointly with the final head using the Deep SVDD loss. Collapse is prevented by fixed nonzero centers and no biases, following Deep SAD. We also sweep $\tau$, because it moves smoothly between the average and max baselines, and we report where on that axis performance peaks.

The analysis has three parts. First, we measure recall as a function of defect size. Defect area comes from the pixel masks in MVTec AD, and we look at how recall falls off as input resolution is reduced. Second, we check whether the free-logit LIP variant learns to down-weight rare textures under one-class training. This would be the mechanism behind our prediction that it fails. Third, we check whether channel gates fire on dust when dust appears in the normal training set.

Baselines

The naive reference is FPSVDD-style average pooling, rerun in our code with the same backbone, input resolution and head. The published figure is a mean image AUROC of 91.6% on MVTec AD (FPSVDD). Patch SVDD's reported 0.921 image and 0.957 segmentation AUROC (Patch SVDD) is a second hypersphere reference.

The strongest existing method is Reverse Distillation. It reports 98.5% image AUROC, 97.8% pixel AUROC and 93.9% PRO on MVTec AD (Reverse Distillation). PRO is per-region overlap, a localization metric that weights each defect region equally regardless of size. We run the official configuration at the same input resolutions as ours, on the same frozen backbone family, with matched training epochs. We do not expect to beat it on whole-benchmark averages at full resolution. Beating it means higher PRO and higher recall on the smallest third of defects, measured by mask area, at reduced resolutions (128 and 64 pixels) under matched FLOPs, while staying within about one point on overall image AUROC.

FRE runs with PCA on the same layers. The file contains no reported aggregate result on Lacuna for FRE on MVTec AD, so its numbers will be our own. The ablations that isolate the key ingredient are three: max pooling, free-logit LIP trained one-class, and a global-average Squeeze-and-Excitation block made bias-free. All variants get the same hyperparameter search budget, 20 configurations each selected on a held-out set of normal images only, because defect labels must not leak into tuning.

Why not just…?

Why not just use max pooling? Max pooling keeps extreme values, but it keeps extremes in raw feature magnitude, not extremes in abnormality. High-contrast normal structure such as grid lines, screw threads and specular highlights will win windows. Dust will win them too. This is a real threat on textures with bland backgrounds, and on such classes max pooling may match us. The $\tau$ sweep and the dusty-normal experiment below settle it: our method should beat max pooling specifically where normal images contain high-contrast content.

Why not just score the fine-scale layers directly and fuse the maps afterwards? This is the most serious alternative, because Reverse Distillation and FRE already score multiple layers. If a late fusion (the maximum over the fine-scale distance map and the coarse distance map) matches our method, then carrying abnormality inside the network adds nothing, and the idea reduces to multi-scale scoring. Our hypothesis is that early layers lack context, so fine-scale distances fire on every unusual texture. Routing those distances into deeper layers should let context suppress false alarms. We run this late-fusion baseline explicitly, and we will report it as the result if it wins.

Why not just feed full-resolution images or tile them? Tiling avoids downsampling at a linear cost in compute. That cost is exactly what edge deployment on 400 MB line-scan frames cannot pay: Smart-Inspect already needs 10 to 20 seconds per frame. We report the accuracy of each method against its FLOPs, so a tiled baseline appears on the same curve.

Why not just train a supervised defect classifier? The ACCC results show supervised models excel on closed defect sets: 98.39% accuracy for SE-ResNet18. However, Deep SAD reports that supervised models overfit to the defect types they were trained on and miss new ones. Our leave-one-defect-out test on ACCC measures this directly.

Proposed Experiments

The main benchmark is MVTec AD. We report image AUROC, pixel AUROC and PRO at input resolutions of 256, 128 and 64, stratified by defect area. The decisive check has two conditions. Our method must lose less small-defect PRO than average pooling and Reverse Distillation as resolution drops. It must also beat late fusion at matched FLOPs.

The second experiment uses ACCC X-ray scans (SE-ResNet18) as a one-class problem. We train on the "No Defect" images only and report per-class recall for Splitting, Sawing, Fracture and Displacement. The supervised Splitting recall of 94.0% serves as a ceiling reference, not as a like-for-like comparison.

The third experiment uses the smartphone-glass patches from Smart-Inspect, if the authors can supply them. Clean glass is the normal class. We train one version with dust patches included among the normals and one without, and we measure the rate at which scratches and pits are confused with dust. The prediction is that normality-referenced gates learn to ignore dust once dust counts as normal, and that max pooling does not. The supervised reference is the reported drop from 97.77% accuracy on clean glass to about 75% in dusty conditions.

A negative result on any single one of these checks narrows the claim rather than hiding it. If late fusion matches us, the contribution reduces to the analysis of where one-class detectors lose small defects.