Skip to main content
Resume
← All projects

Computer vision

makroInspect

An industrial anomaly-detection pipeline combining instance segmentation, dense visual features, and normal-sample memory banks.

An anomaly heatmap localizing a defect on an industrial inspection sample
Representative anomaly localization output: predicted heatmap over a defect region.
Status Active project · 2026
Technologies
  • Python
  • PyTorch
  • SAM3
  • DINOv2
  • PatchCore-style memory bank
  • CUDA
  • OpenCV
  • MVTec AD
  • VisA

Overview

makroInspect is a training-free industrial anomaly-detection system. It learns the distribution of normal visual patches from defect-free examples and identifies test regions whose features are far from that reference set.

The system is organized as a reusable, configurable pipeline rather than a single research notebook, with an offline artifact-caching model: prepare, segment, embed, score, and evaluate stages each produce cached, config-tracked outputs.

From course project to makroInspect

The work began as a University of Victoria course project, now documented in this portfolio as DinoPatch. That original implementation established the core training-free approach: learn nominal appearance from defect-free examples, segment and align objects, extract DINO-family visual features, score anomalies against a nearest-neighbour memory bank, and evaluate the method on industrial anomaly datasets. Its promising results demonstrated that the approach was viable and provided the foundation for continued development.

After the course project, Mattias continued developing the system independently. The current makroInspect repository is a substantially redesigned and more capable implementation — not the same system described in the original report. It advances the pipeline with SAM3 + DINOv2, PCA alignment, k-center memory-bank selection, improved spatial anomaly scoring, pixel-level evaluation, reproducible artifact caching and invalidation, and broader benchmark coverage. All current performance claims below come from the newer audited 27-category results.

Problem and context

Industrial inspection often has many examples of normal parts but relatively few representative defects. A useful system must therefore learn from normal data, preserve spatial detail for localization, and remain practical when experiments span many object categories and configuration variants.

Objects may also appear more than once or in inconsistent orientations. Treating the whole frame as one sample can dilute a small defect or make normal positional variation look anomalous.

Technical approach

SAM3 first segments individual foreground instances where applicable. Each mask is converted into a consistently oriented crop using principal-component alignment before DINOv2 ViT-B/14 produces a dense grid of patch embeddings.

A PatchCore-style memory bank represents normal features. K-center selection bounds the bank size, spatial cosine-distance nearest-feature comparisons produce heatmaps, and Gaussian refinement turns those maps into localization and image-level scores.

Key engineering details

Stage architecture

Prepare, segmentation, cropping, embedding, bank construction, heatmap generation, refinement, and scoring are explicit pipeline stages with stable, file-based artifact boundaries — CSV/JSON run metadata and config snapshots, not a database.

Caching and invalidation

Configuration tracking cascades: changing a stage config invalidates only that stage and its downstream dependants, so category-specific configuration can be iterated without recomputing everything.

Category-specific configuration

Each of the 27 categories can use its own segmentation, cropping, and scoring configuration, with per-category runs recorded independently for reproducibility.

Evaluation

Run metadata records image AUROC, pixel AUROC, and per-defect breakdowns alongside the configuration that produced them, enabling apples-to-apples comparison across runs.

Bar chart of macro-average image and pixel AUROC aggregated by MVTec AD and VisA
Aggregate image/pixel AUROC by dataset (MVTec AD vs. VisA).
Per-category image AUROC across all 27 scored categories
Per-category image AUROC across all 27 scored categories, sorted by score.

Results and outcomes

The current audited benchmark covers 27 scored categories — all 15 MVTec AD categories and all 12 VisA categories — across 3,887 test images, reaching a 98.77% macro-average image-level AUROC and 97.56% macro-average pixel-level AUROC.

By dataset: MVTec AD reaches 99.1% image / 96.9% pixel AUROC; VisA reaches 98.4% image / 98.4% pixel AUROC. These are category-level macro averages, not pooled per-image scores. An earlier, independently verified 26-category cohort reported 98.9% average image AUROC; the 27-category result above is the current, more complete benchmark.

Limitations and failure cases

  • Weakest current image-level category: MVTec AD cable, at 94.45% AUROC. Weakest pixel-level localization: wood, at 92.48% pixel AUROC.
  • No defensible MVTec LOCO accuracy claim, and no MVTec AD2 experiment evidence yet — the pipeline supports those datasets as inputs but has not been benchmarked against them.
  • No controlled memory-bank-size sensitivity study and no repeated-seed uncertainty estimates; bank construction via k-center selection is stochastic, so a single run’s score is a point estimate, not a confidence interval.
  • No current full end-to-end production throughput benchmark, and no state-of-the-art claim — this is a benchmarked research pipeline, not a deployed inspection system.