← Selected work

Completed team project · Computer vision · MVTec AD

Industrial Visual Anomaly Detection

A normal-only industrial inspection project that grew from exploratory analysis into a reproducible comparison of convolutional autoencoders, PatchCore, DINOv2 and DINOv3 across all 15 MVTec AD categories.

MVTec ADPatchCoreDINOv2 / DINOv3AUPIMOfair-eval-v1

Project in 60 seconds

The core problem was to detect and localize defects when training data is overwhelmingly normal and the defective region can occupy only a tiny fraction of an image. We treated image-level detection and pixel-level localization as separate evaluation questions, then rebuilt the comparison around a common deterministic protocol so model conclusions were actually comparable.

15MVTec AD categories
0.941DINOv2 mean image F1
0.680DINOv3 mean AUPIMO
1.54%median defect area
My contribution.

Exploratory analysis and reporting; metric and threshold design; autoencoder and ResNet experiments; PatchCore implementation/evaluation; fair deterministic evaluation corrections; and DINOv2/DINOv3 experiments using patch-level representations and nearest-neighbour anomaly scoring. The integrated repository is a team artifact and also contains substantial work by Benjamin Förster, Mahboubeh Nadaf and Karim Khalifa.

Industrial anomaly detection and localization overview showing the MVTec AD dataset, fair evaluation protocol, explored models, final fair-eval-v1 metrics, and practical quality-control takeaways
Project overview. Vector summary of the normal-only learning setup, shared evaluation protocol, final model comparison and practical inspection workflow. Open the image for the full-resolution view.

Why this was harder than a normal image classifier

Industrial anomaly detection is an open-ended problem: training data contains many good parts, defects are rare, and a future defect may not resemble any labeled failure seen during development. The useful setup is therefore to learn what “normal” looks like and score deviations from that reference.

The localization problem was particularly imbalanced. The median defective region occupied about 1.54% of an image, one quarter occupied less than 0.49%, and some defects were around 0.037%. That made apparently strong pixel metrics easy to misread and pushed us toward low-false-positive localization metrics and qualitative inspection.

3,629normal training images
467normal test images
1,258defective test images

Final comparison under one protocol

After correcting data membership, threshold calibration and metric paths, all models were compared under fair-eval-v1. Image F1 was the primary deployed decision metric; PR-AUC provided threshold-independent context; AUPIMO measured localization under a strict low-false-positive regime.

ModelImage F1Image PR-AUCAUPIMO
DINOv2, single-layer 1-NN0.9410.9890.602
DINOv3, single-layer 1-NN0.9320.9860.680
PatchCore0.9290.9880.603
DINOv2, enhanced0.9200.9830.545
Keras CAE0.4950.8670.058

The most useful result was not simply which model scored highest. A comparatively simple frozen representation plus nearest-neighbour memory performed extremely well, while a more elaborate DINOv2 variant improved some pixel metrics but reduced image F1 and AUPIMO. Complexity had to earn its place.

The project became an ML system, not a notebook collection

The final repository includes deterministic manifests and splits, Pixi environments, tests and linting, model-artifact caching, FastAPI and Streamlit interfaces, preprocessing components, explicit evaluation workflows and a defense-oriented inspection surface. Reproducibility and protocol identity became part of the modelling work rather than cleanup at the end.

Operational path
Datasetmanifest + exact paths
→
Preprocessshared transforms
→
ModelCAE / PatchCore / DINO
→
EvaluateF1, PR-AUC, AUPIMO
→
InspectStreamlit + heatmaps

Technical deep dives

The detailed material is separated by question so the overview stays readable without losing the technical record.

What I would carry into another anomaly-detection project

Separate ranking from operating point.

PR-AUC describes ranking across thresholds; precision, recall and F1 describe behavior after choosing one.

Protocol engineering is ML work.

Reproducible splits, cache identity, threshold provenance and metric consistency can change the conclusion as much as a new model.

Inspect maps, not only scalar metrics.

A global score can hide spatially ugly false positives or missed small defects.

Start simple enough to explain.

A strong frozen representation plus nearest-neighbour scoring can reveal whether additional architectural complexity is justified.