Chapter 13 β Anomaly Detection
βTrain only on normal β detect everything else. Anomaly detection is the art of defining and defending normalcy.β
Problem Formulation
Planned content: One-class learning: only normal samples available during training. Detect deviations at inference. Three levels: image-level (is this image anomalous?), pixel-level (which pixels are anomalous?), and region-level. Industrial inspection, medical screening, fraud detection, surveillance.
π Planned diagram: Anomaly detection taxonomy β image-level vs. pixel-level, and the three method families (reconstruction, embedding, normalizing flow).
Reconstruction-Based Methods
Planned content: Autoencoder (AE): train to reconstruct normal images. Anomalies β high reconstruction error. VAE: adds probabilistic latent space. Patch-level reconstruction. Limitation: AEs can also reconstruct anomalies well (the over-generalization problem). Memory-augmented AE (MemAE) to constrain the latent space.
π Planned diagram: Autoencoder anomaly detection β normal image β AE β low error; anomalous image β AE β high error residual map.
Embedding-Based Methods
Planned content: PatchCore: extract patch features with ImageNet pre-trained ResNet, build a coreset (representative subset of training patch features), score test patches by distance to nearest neighbor in coreset. SPADE: KNN in feature space. Gaussian discriminant (Mahalanobis distance on features). No training beyond feature extraction.
π Planned diagram: PatchCore pipeline β training: extract patch features
[N_patches, D]β coreset subsampling β memory bank. Inference: test patch features β KNN distance β anomaly score map.
Normalizing Flow Methods
Planned content: Learn a bijective mapping from feature space to a standard Gaussian (base distribution). High likelihood β normal. Low likelihood β anomaly. FastFlow, CFLOW-AD. Advantages: exact likelihood, no AE over-generalization.
π Planned diagram: Normalizing flow for anomaly detection β features β flow network β latent Gaussian β negative log-likelihood as anomaly score.
Knowledge Distillation Methods
Planned content: Student-teacher: teacher (ImageNet pretrained, fixed) and student (trained to mimic teacher on normals). At inference: discrepancy between teacher and student features is the anomaly score. RD4AD, SimpleNet. Efficient and competitive.
Student-Teacher Feature Matching
Planned content: Teacher network produces
[B, C, H/s, W/s]feature maps. Student learns to produce identical features for normal inputs. Anomaly score: L2 distance between teacher and student feature maps.
Industrial Inspection and MVTec Benchmark
Planned content: MVTec AD dataset: 15 categories (textures + objects), 73 anomaly types. Evaluation: image-level AUROC, pixel-level AUROC, PRO (Per-Region Overlap). Current SOTA ~99% image AUROC. VisA benchmark for multi-class setting. Real-world challenges: multi-class, few-shot, continual.
π Planned diagram: MVTec AD sample categories β showing normal and anomalous samples for metal nut, leather, wood, etc.
Next: Chapter 14 β OCR & Document Understanding β
Last updated: May 2026