Skip to content

s12359e/SimpleNet

 
 

Repository files navigation

SimpleNet

SimpleNet: A Simple Network for Image Anomaly Detection and Localization

Zhikang Liu, Yiming Zhou, Yuansheng Xu, Zilei Wang*

Paper link

Introduction

This repo contains source code for SimpleNet implemented with pytorch.

SimpleNet is a simple defect detection and localization network that built with a feature encoder, feature generator and defect discriminator. It is designed conceptionally simple without complex network deisng, training schemes or external data source.

Get Started

Environment

Python3.8

Packages:

  • torch==1.12.1
  • torchvision==0.13.1
  • numpy==1.22.4
  • opencv-python==4.5.1

(Above environment setups are not the minimum requiremetns, other versions might work too.)

Data

Edit run.sh to edit dataset class and dataset path.

Custom datasets

If your data is stored in a single-class folder that follows the MVTec directory layout (for example zipper/train/good and zipper/test/...), you can use the new custom dataset option. The loader automatically walks up the directory tree from the provided data_path until it finds the folder that contains the train/test splits, so both zipper and zipper/train/good are accepted. Update your command to use custom as the dataset name, e.g.

python3 main.py \
  ... \
  dataset \
  --batch_size 8 \
  --resize 329 \
  --imagesize 288 \
  -d zipper \
  custom /path/to/zipper/train/good

Only the train directory is required, but if a ground_truth folder is present it will be used automatically for anomaly masks during testing.

MvTecAD

Download the dataset from here.

The dataset folders/files follow its original structure.

Run

Demo train

Please specicy dataset path (line1) and log folder (line10) in run.sh before running.

run.sh gives the configuration to train models on MVTecAD dataset.

bash run.sh

Citation

@inproceedings{liu2023simplenet,
  title={SimpleNet: A Simple Network for Image Anomaly Detection and Localization},
  author={Liu, Zhikang and Zhou, Yiming and Xu, Yuansheng and Wang, Zilei},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={20402--20411},
  year={2023}
}

Acknowledgement

Thanks for great inspiration from PatchCore

License

All code within the repo is under MIT license

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 98.7%
  • Shell 1.3%