GithubHelp home page GithubHelp logo

anomaly-detection-on-mvtec's Introduction

Anomaly Detection on MVTec dataset

This repo. is the implementation of ICLR 2020 paper, "ITERATIVE ENERGY-BASED PROJECTION ON A NORMAL DATA MANIFOLD FOR ANOMALY LOCALIZATION", on Pytorch.

Paper link: https://arxiv.org/abs/2002.03734

The network architecture and training details are same as "Improving Unsupervised Defect Segmentation by Applying Structural Similarity To Autoencoders".

training phase

python3 train.py --data_root ./mvtec_anomaly_detection --category grid --gpu 0 --epochs 20000 --model_type 'ae'
  • data_root: Please refer to the path up to the MVTec dataset directory.
  • category: Please select the category that you want to train.
  • model_type: Please choose the model type from ae or vae.

evaluation phase (anomaly detection)

python3 evaluation.py --gpu 0 --model_path ./checkpoint/grid/model --data_root ./mvtec_anomaly_detection --category grid --model_type 'ae' --use_grad
  • model_path: Please refer to the trained model path.
  • data_root: Please refer to the path up to the MVTec dataset directory.
  • category: Please select the category that you want to evaluate.
  • model_type: Please choose the model type from ae or vae.
  • use_grad: If you activate this argument, start to iterative update using model gradients.

Dataset

This implementation presupporses to use MVTec AD, so if you'd like to excuse this, you should get MVTec AD bellow link.
MVTec AD: https://www.mvtec.com/company/research/datasets/mvtec-ad

Categories

Textures
  • carpet
  • grid
  • leather
  • tile
  • wood
Objects
  • bottle
  • cable
  • capsule
  • hazelnut
  • metalnut
  • pill
  • screw
  • toothbrash
  • transistor
  • zipper

data structures

mvtec_anomaly_detection
 |--bottle
 |  |--ground_truth
 |  |  |--broken_large
 |  |  |  |--000_mask.png
 |  |  |  |     :
 |  |  |--broken_small
 |  |  |  |--000_mask.png
 |  |  |  |     :
 |  |  |--contamination
 |  |  |  |--000_mask.png
 |  |  |  |     :
 |  |--test
 |  |  |--broken_large
 |  |  |  |--000.png
 |  |  |  |     :
 |  |  |--broken_small
 |  |  |  |--000.png
 |  |  |  |     :
 |  |  |--contamination
 |  |  |  |--000.png
 |  |  |  |     :
 |  |  |--good
 |  |  |  |--000.png
 |  |  |  |     :
 |  |--train
 |  |  |--good
 |  |  |  |--000.png
 |  |  |  |     :
 |  |--license.txt
 |  |--reaadme.txt
 |--cable
 |    :
 |--license.txt
 |--mvtec_anomaly_detection.tar
 |--readme.txt

Docker file

This dockerfile contains the necessary modules to run this code. Firstly, please build a docker image with Dockerfile, and then run a docker container.

cd docker_file
docker build -t [REPOSITORY]:[TAG] .   Build docker image
docker run --runtime=nvidia -it --rm -p [port number]:8888 -v [local directory path]:/root --name [container name] --ipc=host [REPOSITORY]:[TAG]

If you'd like to use Jupyter lab, you execute set_jupyter_lab.sh after ran a docker container, please.

chmod 777 set_jupyter_lab.sh
./set_jupyter_lab.sh

Requirements

Pytorch: over 1.7.x
scikit-image
sklearn
tqdm
PIL

anomaly-detection-on-mvtec's People

Contributors

hirokiadachi avatar naok0615 avatar

Watchers

 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.