CPR
This is an official implementation of the paper : "Target before Shooting: Accurate Anomaly Detection and Localization under One Millisecond via Cascade Patch Retrieval" (Accepted by IEEE TIP)
Install / Use
/learn @flyinghu123/CPRREADME
CPR
Official PyTorch implementation of CPR
Datasets
We use the MVTec AD dataset for experiments. And use DTD data set to simulate anomalous image.
The data directory is as follows:
data
├── dtd
│ ├── images
│ ├── imdb
│ └── labels
└── mvtec
├── bottle
│ ├── ground_truth
│ ├── license.txt
│ ├── readme.txt
│ ├── test
│ └── train
...
└── zipper
├── ground_truth
├── license.txt
├── readme.txt
├── test
└── train
Installation
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip install -r requirements.txt
generate foreground and global retrieval result
python tools/generate_foreground.py
python tools/generate_retrieval.py
Training
generate synthetic data
python tools/generate_synthetic_data.py -fd log/foreground_mvtec_DenseNet_features.denseblock1_320
bash train.sh
Testing
python test.py -fd log/foreground_mvtec_DenseNet_features.denseblock1_320/ --checkpoints weights/{category}.pth
Pretrained Checkpoints
Download pretrained checkpoints here and put the checkpoints under <project_dir>/weights/.
Baidu Netdisk: https://pan.baidu.com/s/1FTE4b2G8nVZt4lUyaP-kIQ?pwd=ky7j
Acknowledgement
We borrow some codes from PatchCore, MemSeg and SuperPoint
Citation
@ARTICLE{10678861,
author={Li, Hanxi and Hu, Jianfei and Li, Bo and Chen, Hao and Zheng, Yongbin and Shen, Chunhua},
journal={IEEE Transactions on Image Processing},
title={Target Before Shooting: Accurate Anomaly Detection and Localization Under One Millisecond via Cascade Patch Retrieval},
year={2024},
volume={33},
number={},
pages={5606-5621},
keywords={Accuracy;Anomaly detection;Measurement;Standards;Prototypes;Image retrieval;Image reconstruction;Anomaly detection;image patch retrieval;metric learning},
doi={10.1109/TIP.2024.3448263}
}
Related Skills
node-connect
331.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
81.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
331.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
81.5kCommit, push, and open a PR
