zeddo123 / WinCLIP

Implementation of CVPR'23 paper "WinCLIP: Zero-/few-shot anomaly classification and segmentation". It successfully reproduces the same zero-/few-shot AD performance as that in the original paper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinCLIP

Unofficial Implementation of CVPR'23 paper "WinCLIP: Zero-/few-shot anomaly classification and segmentation".

Setup

  • python >= 3.10.11
  • torch >= 1.13.0
  • torchvision >= 0.14.0
  • scipy >= 1.10.1
  • scikit-image >= 0.21.0
  • numpy >= 1.24.3
  • tqdm >= 4.64.0

Device

Single NVIDIA GeForce RTX 3090

Run

Step 1. Setup the Anomaly Detection dataset

Download the Anomaly Detection Dataset and convert it to MVTec AD format. (For datasets we used in the paper, we provided the convert script)

The dataset folder structure should look like:

DATA_PATH/
    subset_1/
        train/
            good/
        test/
            good/
            defect_class_1/
            defect_class_2/
            defect_class_3/
            ...
    ...

Step 2. Quick Start

Change the values of dataset_root_dir, datasetname, shot (in main.py) and OBJECT_TYPE (in mvtec_dataset.py). For example, if run on the category candle of visa with k=2:

dataset_root_dir = "/visa_anomaly_detection"
datasetname = "visa"
shot = 0

OBJECT_TYPE = ["candle"]

and run

python main.py

Citation

This implementation is used to produce the WinCLIP results in our CVPR'24 InCTRL paper. If you find the implementation useful, we would appreciate your acknowledgement via citing the InCTRL paper:

@inproceedings{zhu2024toward,
  title={Toward Generalist Anomaly Detection via In-context Residual Learning with Few-shot Sample Prompts},
  author={Zhu, Jiawen and Pang, Guansong},
  booktitle={Proceedings of the IEEE/CVF conference on computer vision and pattern recognition},
  year={2024}
}

About

Implementation of CVPR'23 paper "WinCLIP: Zero-/few-shot anomaly classification and segmentation". It successfully reproduces the same zero-/few-shot AD performance as that in the original paper.

License:GNU General Public License v3.0


Languages

Language:Python 100.0%