[ECCV 2024] OneNIP

January 18, 2026 · View on GitHub

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.

  • Unsupervised Reconstruction reconstructs normal tokens;
  • Unsupervised Restoration restores pseudo anomaly tokens to the corresponding normal tokens;
  • Supervised Refiner refines reconstruction/restoration errors to achieve more accurate anomaly segmentation.

1. Comparsions of OneNIP and UniAD

Alt text

2. Results and checkpoints-v2.

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

DatasetInput-ReslutionI-AUROCP-AUROCP-AUAPcheckpoints-v2Test-Log
Medical224 ×\times 22484.197.346.1model weighttestlog
MVTec224 ×\times 22498.097.963.9model weighttestlog
MVTec256 ×\times 25697.997.964.8model weighttestlog
MVTec320 ×\times 32098.498.066.7model weighttestlog
VisA224 ×\times 22492.898.742.5model weighttestlog
VisA256 ×\times 25693.498.944.9model weighttestlog
VisA320 ×\times 32094.898.946.1model weighttestlog
BTAD224 ×\times 22493.297.456.3model weighttestlog
BTAD256 ×\times 25695.297.657.7model weighttestlog
BTAD320 ×\times 32096.097.858.6model weighttestlog
MVTec+VisA+BTAD224 ×\times 22494.698.053.5model weighttestlog
MVTec+VisA+BTAD256 ×\times 25694.998.053.1model weighttestlog
MVTec+VisA+BTAD320 ×\times 32095.697.954.1model 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-v2

Download pre-trained checkpoints-v2 to ./checkpoints-v2

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 built on UniAD. Thank the authors of UniAD for open-sourcing their implementation codes!

Star History

Star History Chart