plutoyuxie / AutoEncoder-SSIM-for-unsupervised-anomaly-detection-

Improving Unsupervised Defect Segmentation by Applying Structural Similarity to Autoencoders
121 stars 25 forks source link
anomaly-localization anomaly-segmentation autoencoder mvtec-ad ssim-loss unsupervised-anomaly-detection

AutoEncoder with SSIM loss

This is a third party implementation of the paper Improving Unsupervised Defect Segmentation by Applying Structural Similarity to Autoencoders.

avatar avatar avatar

Requirement

tensorflow==2.2.0
skimage

Datasets

MVTec AD datasets https://www.mvtec.com/company/research/datasets/mvtec-ad/

Code examples

Step 1. Set the DATASET_PATH variable.

Set the DATASET_PATH to the root path of the downloaded MVTec AD dataset.

Step 2. Train SSIM-AE and Test.

Overview of Results

Classification
During test, I simply classify a test image as defect if there is any anomalous response on the residual map. It is strict for anomaly-free images, resulting in relatively lower accuracy in the ok column shown as below.
Please note that the threshold makes a big difference to the outcome, which should be carefully selected.

ok nok average
bottle 90.0 98.4 96.4
cable 0.0 45.7 28.0
capsule 34.8 89.6 78.0
carpet 42.9 98.9 88.9
grid 100 94.7 96.2
hazelnut 55.0 98.6 82.7
leather 71.9 92.4 87.1
metal nut 22.7 67.7 59.1
pill 11.5 75.9 65.9
screw 0.5 90.0 68.1
tile 100.0 3.6 30.8
toothbrush 83.3 100 95.2
transistor 23.3 97.5 53.0
wood 89.5 76.7 79.7
zipper 68.8 81.5 78.8

*SSIM loss, 200 epochs, different threshold

Discussion

Supplementary materials

My notes https://www.yuque.com/books/share/8c7613f7-7571-4bfa-865a-689de3763c59?# password ixgg

References

@inproceedings{inproceedings, author = {Bergmann, Paul and Löwe, Sindy and Fauser, Michael and Sattlegger, David and Steger, Carsten}, year = {2019}, month = {01}, pages = {372-380}, title = {Improving Unsupervised Defect Segmentation by Applying Structural Similarity to Autoencoders}, doi = {10.5220/0007364503720380} }

Paul Bergmann, Michael Fauser, David Sattlegger, Carsten Steger. MVTec AD - A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection; in: IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019