MvtecAD unsupervised Anomaly Detection

Overview

MvtecAD unsupervised Anomaly Detection

This respository is the unofficial implementations of DFR: Deep Feature Reconstruction for Unsupervised Anomaly Segmentation

Result of 500 epochs trained model

Selects latent sizes of Autoencoder by PCA

Classes latent size Segmentation AUC Detection AUC
bottle 116 97.2771% 99.8413%
cable 557 95.5101% 84.8951%
capsule 162 98.8928% 97.3275%
carpet 245 97.9116% 90.5297%
grid 145 97.2484 79.5322%
hazelnut 459 98.5848% 100%
leather 325 98.8649% 95.4484%
metal_nut 380 96.127% 97.263%
pill 292 98.0543% 94.108%
screw 283 99.3001% 92.0066%
tile 557 89.4887% 91.7388%
toothbrush 243 98.6729% 91.3889%
transistor 333 83.9157% 89.0833%
wood 364 91.7027% 98.9474%
zipper 115 95.6663% 83.2983%
mean 95.8141% 92.3606

How to run

requirements

pytorch scikit-learn matplotlib numpy pandas PIL wget

Train

python main.py --mode          train      
               --data_dir_head [Datapath] 
               --BATCH_SIZE    [BATCH_SIZE] 
               --LR            [Learning Rate] 
               --EPOCH         [Epochs] 
               --backbone      [Feature map of Conv in VGG19]
               --latent_dim    [Latent size of CAE] 
               --classes       [Default is all] 

Download 500 Epochs Finetuned Models

Here provide the model of each classes in Drophox

python main.py --mode download                   

Evaluate the ROC-AUC of Test Set

python main.py --mode        evaluation    
               --classes     [Default is all] 

Inference the model

python main.py --mode           inference    
               --heatmap_path   [Input path] 
               --heatmap_item   [Class of input] 
               --heatmap_gt     [GT path Default is None]
               --device         [cpu or cuda]
               --device         [Output path ]         

Example run in main.py

if __name__ == "__main__":  
    cfg = config()
    cfg.mode = "inference"
    cfg.heatmap_path = 'mvtecad_unsupervise/bottle/test/broken_small/001.png'
    cfg.heatmap_item = 'bottle'
    cfg.heatmap_gt = 'mvtecad_unsupervise/bottle/ground_truth/broken_small/001_mask.png'
    cfg.device = 'cpu'
    cfg.heatmap_export = 'validate/Inferece.png'

validate/Inferece.png is

Code Reference

https://github.com/YoungGod/DFR

https://www.kaggle.com/danieldelro/unsupervised-anomaly-segmentation-of-screw-images

You might also like...
Unofficial implementation of PatchCore anomaly detection
Unofficial implementation of PatchCore anomaly detection

PatchCore anomaly detection Unofficial implementation of PatchCore(new SOTA) anomaly detection model Original Paper : Towards Total Recall in Industri

MemStream: Memory-Based Anomaly Detection in Multi-Aspect Streams with Concept Drift
MemStream: Memory-Based Anomaly Detection in Multi-Aspect Streams with Concept Drift

MemStream Implementation of MemStream: Memory-Based Anomaly Detection in Multi-Aspect Streams with Concept Drift . Siddharth Bhatia, Arjit Jain, Shivi

LogDeep is an open source deeplearning-based log analysis toolkit for automated anomaly detection.
LogDeep is an open source deeplearning-based log analysis toolkit for automated anomaly detection.

LogDeep is an open source deeplearning-based log analysis toolkit for automated anomaly detection.

Code for the paper "TadGAN: Time Series Anomaly Detection Using Generative Adversarial Networks"

TadGAN: Time Series Anomaly Detection Using Generative Adversarial Networks This is a Python3 / Pytorch implementation of TadGAN paper. The associated

Industrial knn-based anomaly detection for images. Visit streamlit link to check out the demo.
Industrial knn-based anomaly detection for images. Visit streamlit link to check out the demo.

Industrial KNN-based Anomaly Detection ⭐ Now has streamlit support! ⭐ Run $ streamlit run streamlit_app.py This repo aims to reproduce the results of

A PyTorch implementation of
A PyTorch implementation of "ANEMONE: Graph Anomaly Detection with Multi-Scale Contrastive Learning", CIKM-21

ANEMONE A PyTorch implementation of "ANEMONE: Graph Anomaly Detection with Multi-Scale Contrastive Learning", CIKM-21 Dependencies python==3.6.1 dgl==

Deep Anomaly Detection with Outlier Exposure (ICLR 2019)
Deep Anomaly Detection with Outlier Exposure (ICLR 2019)

Outlier Exposure This repository contains the essential code for the paper Deep Anomaly Detection with Outlier Exposure (ICLR 2019). Requires Python 3

Patch SVDD for Image anomaly detection

Patch SVDD Patch SVDD for Image anomaly detection. Paper: https://arxiv.org/abs/2006.16067 (published in ACCV 2020). Original Code : https://github.co

Comments
  • Inference model error

    Inference model error

    @FieldTien Thank for your hard work. I try to Inference using myself data, but I don't have the mask image for the ground_truth folder. Therefore, I can't make the threshold.pkl, resulting in a lack of the threshold.pkl file when I Inference myself data. What should I do?

    Last, using DataLoader.py: [Errno 2] No such file or directory: 'mvtecad_unsupervise/transistor/ground_truth/damaged_case/008_mask.png'

    opened by VivizSun 0
Owner
null
Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy" (ICLR 2022 Spotlight)

About Code release for Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy (ICLR 2022 Spotlight)

THUML @ Tsinghua University 221 Dec 31, 2022
This is an unofficial implementation of the paper “Student-Teacher Feature Pyramid Matching for Unsupervised Anomaly Detection”.

This is an unofficial implementation of the paper “Student-Teacher Feature Pyramid Matching for Unsupervised Anomaly Detection”.

haifeng xia 32 Oct 26, 2022
USAD - UnSupervised Anomaly Detection on multivariate time series

USAD - UnSupervised Anomaly Detection on multivariate time series Scripts and utility programs for implementing the USAD architecture. Implementation

null 116 Jan 4, 2023
Official PyTorch code for WACV 2022 paper "CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows"

CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows WACV 2022 preprint:https://arxiv.org/abs/2107.1

Denis 156 Dec 28, 2022
(JMLR'19) A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)

Python Outlier Detection (PyOD) Deployment & Documentation & Stats Build Status & Coverage & Maintainability & License PyOD is a comprehensive and sca

Yue Zhao 6.6k Jan 3, 2023
Streaming Anomaly Detection Framework in Python (Outlier Detection for Streaming Data)

Python Streaming Anomaly Detection (PySAD) PySAD is an open-source python framework for anomaly detection on streaming multivariate data. Documentatio

Selim Firat Yilmaz 181 Dec 18, 2022
A Python Library for Graph Outlier Detection (Anomaly Detection)

PyGOD is a Python library for graph outlier detection (anomaly detection). This exciting yet challenging field has many key applications, e.g., detect

PyGOD Team 757 Jan 4, 2023
Real-world Anomaly Detection in Surveillance Videos- pytorch Re-implementation

Real world Anomaly Detection in Surveillance Videos : Pytorch RE-Implementation This repository is a re-implementation of "Real-world Anomaly Detectio

seominseok 62 Dec 8, 2022
Paper list of log-based anomaly detection

Paper list of log-based anomaly detection

Weibin Meng 411 Dec 5, 2022
Demo project for real time anomaly detection using kafka and python

kafkaml-anomaly-detection Project for real time anomaly detection using kafka and python It's assumed that zookeeper and kafka are running in the loca

Rodrigo Arenas 36 Dec 12, 2022