Git Product home page Git Product logo

deviation-network-image's Introduction

Explainable Deep Few-shot Anomaly Detection with Deviation Networks

By Guansong Pang, Choubo Ding, Chunhua Shen, Anton van den Hengel

Official PyTorch implementation of "Explainable Deep Few-shot Anomaly Detection with Deviation Networks".

This implementation is for handling image data. For tabular data, the official implementation is available at deviation-network.

Setup

This code is written in Python 3.6 and requires the packages listed in requirements.txt. Install with pip install -r requirements.txt preferably in a virtualenv.

Usage

Step 1. Setup the Anomaly Detection Dataset

Download the Anomaly Detection Dataset and convert it to MVTec AD format. (For datasets we used in the paper, we provided the convert script.) The dataset folder structure should look like:

DATA_PATH/
    subset_1/
        train/
            good/
        test/
            good/
            defect_class_1/
            defect_class_2/
            defect_class_3/
            ...
        ground_truth/
            defect_class_1/
            defect_class_2/
            defect_class_3/
            ...
    ...

NOTE: The ground_truth folder only available when the dataset has pixel-level annotation.

Step 2. Running DevNet

python train.py --dataset_root=./data/mvtec_anomaly_detection \
                --classname=carpet \
                --experiment_dir=./experiment \
                --epochs=50 \
                --n_anomaly=10 \
                --n_scales=2
  • dataset_root denotes the path of the dataset.
  • classname denotes the subset name of the dataset.
  • experiment_dir denotes the path to store the experiment setting and model weight.
  • epochs denotes the total epoch of training.
  • n_anomaly denotes the amount of the know outliers.
  • n_scales denotes the total scales of multi-scales module.

Step 2. Anomaly Explanation

Visualize the localization result of the trained model by the following command:

python localization.py --dataset_root=./data/mvtec_anomaly_detection \
                       --classname=carpet \
                       --experiment_dir=./experiment \
                       --n_anomaly=10 \
                       --n_scales=2

NOTE: use same argument as the training command.

Citation

@article{pang2021explainable,
  title={Explainable Deep Few-shot Anomaly Detection with Deviation Networks},
  author={Pang, Guansong and Ding, Choubo and Shen, Chunhua and Hengel, Anton van den},
  journal={arXiv preprint arXiv:2108.00462},
  year={2021}
}

deviation-network-image's People

Contributors

eipsilly avatar choubo avatar guansongpang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.