Giter VIP home page Giter VIP logo

anomaly-detection-patchsvdd-pytorch's Introduction

Patch SVDD

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

An input image and a generated anomaly map for 'wood' class.

wood

Compatibility

The code runs on python 3.7, pytorch 1.3.1, and torchvision 0.4.2.

Installation

Step 1. Install libraries.

Step 2. Download MVTec AD dataset.

  • Download MVTec AD dataset: Download
  • Untar the 'mvtec_anomaly_detection.tar.xz' file.

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 Patch SVDD.

python main_train.py --obj=bottle --lr=1e-4 --lambda_value=1e-3 --D=64
  • obj denotes the name of the class out of 15 MVTec AD classes.
  • lr denotes the learning rate of Adam optimizer.
  • lambda_value denotes the value of 'lambda' in Eq. 6 of the paper.
  • D denotes the number of embedding dimension (default to 64).

Step 3. Evaluate the trained encoder.

python main_evaluate.py --obj=bottle
  • obj denotes the name of the class.

The script loads the trained encoder saved in ckpts/ directory. Note that the same evaluation procedure is performed at every training epoch in Step 2.

For a quick evaluation, trained encoders for cable and wood classes are included. Training (Step 2) can be skipped for those classes.

Step 4. Obtain anomaly maps.

python main_visualize.py --obj=bottle
  • obj denotes the name of the class.

The script generates and saves anomaly maps for all the test images in the obj class. The genereated maps are saved in anomaly_maps/obj directory.

anomaly-detection-patchsvdd-pytorch's People

Contributors

nuclearboy95 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.