This is an unofficial implementation of Reconstruction by inpainting for visual anomaly detection (RIAD).
- PyTorch 1.5
- sklearn, matplotlib
- kornia ( incompatible with PyTorch>=1.6.0 so far )
The kornia package is used for its medianfilter function. You may find a substitution if you want to get rid of this dependency.
Please check this mosaic.ipynb file
To train RIAD on MVTec AD
dataset:
python train.py --obj zipper --data_path [your-mvtec_ad-data-path]
Then to test:
python test.py --obj zipper --data_path [your-mvtec_ad-data-path] --checkpoint_dir [your-saved-weights-path]
Finally, you will get results like img_ROCAUC (anomaly detection) around 0.97 and pixel_ROCAUC (anomaly segmetation) around 0.98
Vitjan Zavrtanik, Matej Kristan, Danijel Skčaj,
Reconstruction by inpainting for visual anomaly detection,
Pattern Recognition,
2020,
107706,
ISSN 0031-3203
Thanks for the paper authors.
A big thanks to xiahaifeng1995 for contributing most of the codes.