Task-routed hierarchical patch memories for industrial anomaly detection and localization
Abstract
Industrial anomaly inspection must detect and localize defects, but patch-memory methods use one feature hierarchy for both outputs. This creates a task-dependent hierarchy conflict: deeper features aid image discrimination, whereas pixel localization requires spatial evidence weakened by resizing and aggregation. We propose TRHM-PatchCore, a normal only task-routed hierarchical patch-memory framework. At inference, one shared frozen pretrained WideResNet-50-2 extracts layers 1-3 once for two task-specific memory heads. Global aggregates layers 2 and 3, uses all extracted descriptors before 10% coreset selection, and supplies the image anomaly score. Detail aggregates layers 1 and 2, deterministically samples 2,048 descriptors per normal image before the same coreset procedure and supplies the pixel anomaly map. The final system applies fixed task routing rather than score fusion. On all eight MVTec AD 2 TESTpub categories, Global obtains macro-Image AUROC/AP of 0.7520/0.8350, whereas Detail raises macro AU-PRO@0.05 from 0.3681 to 0.4230 and AU-PRO@0.30 from 0.6096 to 0.6905. Across all eight categories, Detail retains macro-AU-PRO gains of +0.0477/+0.0714 under matched descriptor count, +0.0539/+0.0746 under matched storage, and +0.0540/+0.0769 under a matched nearest-neighbor search proxy at FPR limits 0.05/0.30, respectively. Across five matched-budget coreset seeds, the Detail-minus-Coarse AU-PRO gains are +0.0468 (95% CI 0.0437-0.0499) and +0.0692 (0.0667-0.0717) at FPR limits 0.05 and 0.30. On untouched Magnetic Tile, it matches standard PatchCore image metrics; AU-PRO@0.05/@0.30 is 0.5724/0.8124 versus 0.5604/0.7960.