Home

Awesome

[ECCV 2024] OneNIP

Official PyTorch Implementation of Learning to Detect Multi-class Anomalies with Just One Normal Image Prompt, Accepted by ECCV 2024.

Image text

OneNIP mainly consists of Unsupervised Reconstruction, Unsupervised Restoration, and Supervised Refiner. Unsupervised Reconstruction and Unsupervised Restoration share the same encoder-decoder architectures and weights. Supervised Refiner is implemented by two transposed convolution blocks, and each following a 1×1 convolution layer.

1. Comparsions of OneNIP and UniAD

Alt text

2. Results and Checkpoints.

All pre-trained model weights are stored in Google Drive.

DatasetInput-ReslutionI-AUROCP-AUROCP-AUAPCheckpointsTest-Log
MVTec224 $\times$ 22497.997.963.7model weighttestlog
MVTec256 $\times$ 25697.697.964.8model weighttestlog
MVTec320 $\times$ 32097.997.965.9model weighttestlog
VisA224 $\times$ 22492.598.743.3model weighttestlog
VisA256 $\times$ 25693.198.844.9model weighttestlog
VisA320 $\times$ 32094.298.846.1model weighttestlog
BTAD224 $\times$ 22492.697.456.8model weighttestlog
BTAD256 $\times$ 25694.697.657.0model weighttestlog
BTAD320 $\times$ 32095.397.857.6model weighttestlog
MVTec+VisA+BTAD224 $\times$ 22494.598.052.4model weighttestlog

3. Evaluation and Training

3.1 Prepare data

Download MVTec, BTAD, VisA and DTD datasets. Unzip and move them to ./data. The data directory should be as follows.

├── data
│   ├── btad
│   │   ├── 01
│   │   ├── 02
│   │   ├── 03
│   │   ├── test.json
│   │   ├── train.json
│   ├── dtd
│   │   ├── images
│   │   ├── imdb
│   │   ├── labels
│   ├── mvtec
│   │   ├── bottle
│   │   ├── cable
│   │   ├── ...
│   │   └── zipper
│   │   ├── test.json
│   │   ├── train.json
│   ├── mvtec+btad+visa
│   │   ├── 01
│   │   ├── bottle
│   │   ├── ...
│   │   └── zipper
│   │   ├── test.json
│   │   ├── train.json
│   ├── visa
│   │   ├── candle
│   │   ├── capsules
│   │   ├── ...
│   │   ├── pipe_fryum
│   │   ├── test.json
│   │   ├── train.json

3.2 Evaluation with pre-trained checkpoints

Download pre-trained checkpoints to ./checkpoints

cd ./exps
bash eval_onenip.sh 8 0,1,2,3,4,5,6,7

3.3 Training OneNIP

cd ./exps
bash train_onenip.sh 8 0,1,2,3,4,5,6,7

Citing

If you find this code useful in your research, please consider citing us:

@inproceedings{gao2024onenip,
  title={Learning to Detect Multi-class Anomalies with Just One Normal Image Prompt},
  author={Gao, Bin-Bin},
  booktitle={18th European Conference on Computer Vision (ECCV 2024)},
  pages={-},
  year={2024}
}

Acknowledgement

Our OneNIP is build on UniAD. Thank the authors of UniAD for open-sourcing their implementation codes!