Home

Awesome

WinCLIP

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

Setup

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}
}