Skip to content

birkhofflee/industrial_anomoly_detection

Repository files navigation

Industrial anomoly detection with deep learning

This repo serves the source code of the Smart Manufacturing Lab project at Politecnico di Milano.

Setting up the environment

Ensure uv is installed, then:

$ uv sync
$ uv run ipython kernel install --user --env VIRTUAL_ENV $(pwd)/.venv --name=smlab

You can check JupyterLab path using:

$ uv run --with jupyter jupyter --paths

Start the JupyterLab server:

$ uv run --with jupyter jupyter lab

The web interface should automatically launch in your browser.

Models

Model Architecture Training
PaDiM Frozen ResNet-18; multivariate Gaussian per spatial position 1 epoch (single-pass feature collection)
PatchCore Frozen ResNet-18; greedy coreset memory bank (1% sampling) 1 epoch (single-pass feature collection)
EfficientAD Lightweight PDN teacher-student + autoencoder branch 70,000 steps, Adam
RD Frozen Wide ResNet-50-2 encoder + one-class bottleneck + mirrored student decoder 200 epochs, Adam lr=0.005

Results (metal_nut, MVTec AD)

Anomalib Engine Metrics

Model Image AUROC Image F1 Pixel AUROC Pixel F1
PaDiM 0.979 0.968 0.969 0.731
PatchCore 1.000 0.989 0.986 0.825
EfficientAD 1.000 0.989 0.981 0.797
RD 1.000 0.989 0.973 0.797

Binary Classification Report (threshold = 0.5)

Model Accuracy Normal Prec. Normal Rec. Normal F1 Anomaly F1
PaDiM 0.95 0.90 0.82 0.86 0.97
PatchCore 0.98 0.95 0.95 0.95 0.99
EfficientAD 0.95 0.81 0.95 0.88 0.97
RD 0.99 0.96 1.00 0.98 0.99

Qualitative Results

FiftyOne App showing the test split grid view with model prediction fields. Each tile displays the original image, the defect type label, and the predicted anomaly classification for all four models simultaneously.

FiftyOne sample detail view for a "flip" defect. It shows the original image and the anomaly heatmap from RD overlaid on the image.

A "good" (non-defective) sample showing false positive behaviour in PaDiM: elevated anomaly scores localised to background regions rather than the component surface.

License

MIT

About

Industrial AD project at the Smart Manufacturing Lab of Politecnico di Milano

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors