Giter Site home page Giter Site logo

ds2deb's Introduction

Dual Scale Dual Similarity (DS2)

Supported platform:

Linux

Package installation:

conda install the following packages in the recommended order:

  • pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0 -c pytorch
  • scikit-learn
  • python=3.8.8
  • opencv -c conda-forge
  • termcolor -c omnia
  • pillow=9.1.0

MVTec dataset preparation:

Follow the steps to create mvtec dataset (for evaluation stage) and mvtec_train dataset (for pretraining stage)

  • create the dataset folder inside the project root: mkdir dataset
  • move into the folder: cd dataset
  • create the mvtec folder: mdkir mvtec
  • move into the folder: cd mvtec
  • Download MVTec AD dataset: wget https://www.mydrive.ch/shares/38536/3830184030e49fe74747669442f0f282/download/420938113-1629952094/mvtec_anomaly_detection.tar.xz
  • unzip: tar -xf mvtec_anomaly_detection.tar.xz
  • remove zip file: rm mvtec_anomaly_detection.tar.xz
  • move to parent folder (dataset/): cd ..
  • create the mvtec_train folder: mkdir mvtec_train
  • move to parent folder (project root): cd ..
  • run the command ./tools/make_mvtec_train.sh to create the mvtec_train dataset for pretraining (Note: replace the $PROJ_ABS_PATH to the absolute path of your project on your local machine)

MVTec LOCO dataset preparation:

  • visit https://www.mvtec.com/company/research/datasets/mvtec-loco, and fill out the form required in the website to download the dataset
  • once downloaded, unzip the file, rename the outermost folder name to mvtecloco, and move the files to folder DS2/dataset/, such that the breakfast_box category is located at DS2/dataset/mvtecloco/breakfast_box

KSDD2 dataset preparation:

  • download the dataaset: wget https://go.vicos.si/kolektorsdd2 -O KSDD2.zip
  • unzip the file: unzip KSDD2.zip
  • move the train and test folders to DS2/dataset/KSDD2/

MTD dataset preparation:

  • download the dataset: git clone https://github.com/abin24/Magnetic-tile-defect-datasets..git
  • rename the folder name from Magnetic-tile-defect-datasets. to MTD
  • move the MTD folder to DS2/dataset/

Run pretraining code for DS2 on MVTec (Stage 1):

  • To run the pretraining code for DS2, execute ./tools/ds2_pretrain_mvtec.sh. The default setting requires two GPUs (preferably A100-40GB and above). The seed range is [1,5]
  • The output log (including model checkpoints) will be stored in folder output/mvtec_$TIMESTAMP/

Run evaluation code for DS2 on MVTec (Stage 2):

  • After pretraining, execute ./tools/ds2_eval_mvtec.sh to perform anomaly detection on test split. The default setting requires one GPU.
    • Inside file ./tools/ds2_eval_mvtec.sh, set pretrained_model_dir to the checkpoint models' folder output/mvtec_$TIMESTAMP/
  • The evaluation output will be stored in folder logs/

Run pretraining code for CutPaste_(3-way, one-for-all) on MVTec:

  • To run the pretraining code for CutPaste, execute ./tools/cutpaste_pretrain_mvtec.sh. The default setting requires two GPUs (preferably A100-40GB and above). The seed range is [1,5]
  • The output log (including model checkpoints) will be stored in folder output/mvtec_$TIMESTAMP_cutpaste/

Run evaluation code for CutPaste_(3-way, one-for-all) on MVTec:

  • After pretraining, execute ./tools/cutpaste_eval_mvtec.sh to perform anomaly detection on test split. The default setting requires one GPU.
    • Inside file ./tools/cutpaste_eval_mvtec.sh, set pretrained_model_dir to the checkpoint models' folder output/mvtec_$TIMESTAMP_cutpaste/
  • The evaluation output will be stored in folder logs/

Run evaluation code for DS2 on MVTec LOCO:

  • After pretraining, execute ./tools/ds2_eval_loco.sh. The default setting requires one GPU.
    • Inside file ./tools/ds2_eval_loco.sh, set pretrained_model_dir to the checkpoint models' folder output/mvtec_$TIMESTAMP/
  • The evaluation output will be stored in folder logs/

Run evaluation code for DS2 on KSDD2:

  • After pretraining, execute ./tools/ds2_eval_ksdd2.sh. The default setting requires one GPU.
    • Inside file ./tools/ds2_eval_ksdd2.sh, set pretrained_model_dir to the checkpoint models' folder output/mvtec_$TIMESTAMP/
  • The evaluation output will be stored in folder logs/

Run evaluation code for DS2 on MTD:

  • After pretraining, execute ./tools/ds2_eval_mtd.sh. The default setting requires one GPU.
    • Inside file ./tools/ds2_eval_mtd.sh, set pretrained_model_dir to the checkpoint models' folder output/mvtec_$TIMESTAMP/
  • The evaluation output will be stored in folder logs/

Acknowledgement

The main architecture is adapted from https://github.com/zdaxie/PixPro (Propagate Yourself: Exploring Pixel-Level Consistency for Unsupervised Visual Representation Learning)

The implementation of DistAug and RotPred is adapted from https://github.com/google-research/deep_representation_one_class (LEARNING AND EVALUATING REPRESENTATIONS FOR DEEP ONE-CLASS CLASSIFICATION)

The implementation of CutPaste is adapted from https://github.com/Runinho/pytorch-cutpaste

ds2deb's People

Watchers

Haitian He 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.