Code Monkey home page Code Monkey logo

fastrecon's Introduction

FastRecon:Few-shot Industrial Anomaly Detection via Fast Feature Reconstruction

Paper

Paper

In industrial anomaly detection, data efficiency and the ability for fast migration across products become the main concerns when developing detection algorithms. Existing methods tend to be data-hungry and work in the one-model-one-category way, which hinders their effectiveness in real-world industrial scenarios. In this paper, we propose a few-shot anomaly detection strategy that works in a low-data regime and can generalize across products at no cost. Given a defective query sample, we propose to utilize a few normal samples as a reference to reconstruct its normal version, where the final anomaly detection can be achieved by sample alignment. Specifically, we introduce a novel regression with distribution regularization to obtain the optimal transformation from support to query features, which guarantees the reconstruction result shares visual similarity with the query sample and meanwhile maintains the property of normal samples. Experimental results show that our method significantly outperforms previous state-of-the-art at both image and pixel-level AUROC performances from 2 to 8-shot scenarios. Besides, with only a limited number of training samples (less than 8 samples), our method reaches competitive performance with vanilla AD methods which are trained with extensive normal samples.

The code will be available soon.

Overview of our method. Feature maps of each query sample and support samples are exacted by a pre-trained encoder. Features from support images are aggregated into a support feature pool. This pool is down-sampled through greedy coreset selection as $S$ to reduce data redundancy and improve inference speed. The coreset $S$ and the original query feature map $Q$ are then input to our proposed regression with distribution regularization as shown in the grey region. An optimal transformation $\bar{W}$ between $S$ and $Q$ is obtained by the regression to make sure the reconstructed sample $\bar{W} S$, denoted as $\bar{Q}$, to share similarity with $Q$ but keeps all the property of normal samples. Finally, we align $\bar{Q}$ and Q for direct comparison to obtaining the anomaly estimation.

Qualitative results of anomaly localization for both MVTec and MPDD datasets. The first row in the red box presents the support sample for each category while the second row indicates the query samples. The results show that our method can provide accurate localization of defect regions even for more complicated patterns in MPDD.

Usage

This code is based on the project PatchCore_anomaly_detection

# install python 3.6, torch==1.8.1, torchvision==0.9.1
pip install -r requirements.txt

python main.py --phase train or test --dataset_path .../mvtec_anomaly_detection --category carpet --project_root_path path/to/save/results --coreset_sampling_ratio 0.01 --n_neighbors 9

Reference

PatchCore_anomaly_detection

kcenter algorithm

embedding concat function

fastrecon's People

Contributors

fzjun26th avatar

Stargazers

Jiaxiong Yang avatar  avatar Bagheriha.ali avatar Salih Cem ESENER avatar Samet Akcay avatar  avatar Fuquan Dai avatar WangFengJie avatar  avatar leocalle avatar DFan avatar dyy avatar  avatar  avatar André Afonso avatar Taowen wang avatar Gavin Wang avatar  avatar  avatar wyczzy avatar Zilong Zhang avatar ALBERT avatar  avatar Yanyu Xu avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar bill avatar kenjiro tochimoto avatar

fastrecon's Issues

问题

作者你好!我目前也在做few-shot AD相关的研究,请问核心代码是否已完全开源?我在你开源的代码基础上补全了AUROC的计算,并成功运行了代码,部分类别的结果相差不大,但还有一部分类别的结果不尽人意,如MVTec AD数据集toothbrush类IMG-AUROC未超过60%,zipper类也是如此,这与论文中的结果相去甚远。请问是有部分代码未公开吗?还请作者开源这部分代码,谢谢!
zipper:
image
transistor:
image
toothbrush:
image
leather:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.