Skip to content

This is an official implementation of “ Prototypical Learning Guided Context-Aware Segmentation Network for Few-Shot Anomaly Detection” (PCSNet) with PyTorch.

Notifications You must be signed in to change notification settings

yuxin-jiang/PCSNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



PCSNet: Prototypical Learning Guided Context-Aware Segmentation Network for Few-Shot Anomaly Detection

    Yuxin Jiang1      Yunkang Cao1       Weiming Shen1, *
    1Huazhong University of Science and Technology

[GitHub Repository][Paper]

Framework

Abstract: Few-shot anomaly detection (FSAD) denotes the identification of anomalies within a target category with a limited number of normal samples. While pre-trained feature representations play an important role in existing FSAD methods, there exists a domain gap between pre-trained representations and target FSAD scenarios. This study proposes a Prototypical Learning Guided Context-Aware Segmentation Network (PCSNet) to address the domain gap and improve feature descriptiveness in target scenarios. In particular, PCSNet comprises a prototypical feature adaption (PFA) sub-network and a context-aware segmentation (CAS) sub-network. PFA extracts prototypical features as accurate guidance to ensure better feature compactness for normal data while distinct separation from anomalies. A pixel-level disparity classification loss is also designed to make subtle anomalies more distinguishable. Then a CAS sub-network is introduced for pixel-level anomaly localization, where pseudo anomalies are exploited to facilitate the training process. Experimental results on MVTec and MPDD demonstrate the superior FSAD performance of PCSNet, with 94.9% and 80.2% image-level AUROC in an 8-shot scenario, respectively. Real-world applications on automotive plastic part inspection further demonstrate that PCSNet can achieve promising results with limited training samples.

Index Terms: Anomaly detection; Pretrained feature representations; Few-shot learning; Prototypical learning;

💻 Requirements

  • pytorch == 1.12.0
  • torchvision == 0.13.0
  • numpy == 1.21.6
  • scipy == 1.7.3
  • matplotlib == 3.5.2
  • tqdm

🛠️ Framework

Framework

📥 Dataset

Download the MVTec dataset here.

🚀 Usage

Execute the following command for training and evaluation:

python main.py

📊 Quantitative Comparisons

Experiments are conducted on the MVTec AD and MPDD datasets for few-shot anomaly detection and localization.

Quantitative Results

🖼️ Qualitative Visualization (Anomaly Localization)

Visualization results show that PCSNet excels in anomaly localization. It accurately captures large anomalous regions (e.g., hazelnut, cable), precisely localizes small anomalies (e.g., capsule, pill, screw), and detects all multiple anomalous regions without omission (e.g., grid, toothbrush).

Qualitative Results

🏭 Real-World Application: Anomaly Detection on Automotive Plastic Parts

Dataset

An in-house Automotive Plastic Parts Dataset (APPD) is collected to evaluate PCSNet in real-world industrial scenarios.

Dataset

Experimental Results

Qualitative visualizations (Fig. 13) of the automotive plastic parts dataset:

Dataset

📝 Citation

If you find this work useful, please consider citing:

@article{jiang2024prototypical,
  title={Prototypical learning guided context-aware segmentation network for few-shot anomaly detection},
  author={Jiang, Yuxin and Cao, Yunkang and Shen, Weiming},
  journal={IEEE Transactions on Neural Networks and Learning Systems},
  year={2024},
  publisher={IEEE}
}

About

This is an official implementation of “ Prototypical Learning Guided Context-Aware Segmentation Network for Few-Shot Anomaly Detection” (PCSNet) with PyTorch.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages