Collaborative Reconstruction and Repair for Multi-class Industrial Anomaly Detection

December 20, 2025 ยท View on GitHub

Collaborative Reconstruction and Repair for Multi-class Industrial Anomaly Detection

DI(Data Intelligence) 2025

arXiv

PyTorch Implementation of DI 2025 "Collaborative Reconstruction and Repair for Multi-class Industrial Anomaly Detection".

Give me a โญ๏ธ if you like it.

Figure2_1

News

  • 08.12.2025: Accepted by DI 2025๐ŸŽ‰

  • 15.12.2025: We released the arXiv preprint and the GitHub code, and the work was included in the popular industrial anomaly detection repository awesome-industrial-anomaly-detection.๐Ÿš€

Abstract

Industrial anomaly detection is a challenging open-set task that aims to identify unknown anomalous patterns deviating from normal data distribution. To avoid the significant memory consumption and limited generalizability brought by building separate models per class, we focus on developing a unified framework for multi-class anomaly detection. However, under this challenging setting, conventional reconstruction-based networks often suffer from an identity mapping problem, where they directly replicate input features regardless of whether they are normal or anomalous, resulting in detection failures. To address this issue, this study proposes a novel framework termed Collaborative Reconstruction and Repair (CRR), which transforms the reconstruction to repairation. First, we optimize the decoder to reconstruct normal samples while repairing synthesized anomalies. Consequently, it generates distinct representations for anomalous regions and similar representations for normal areas compared to the encoder's output. Second, we implement feature-level random masking to ensure that the representations from decoder contain sufficient local information. Finally, to minimize detection errors arising from the discrepancies between feature representations from the encoder and decoder, we train a segmentation network supervised by synthetic anomaly masks, thereby enhancing localization performance. Extensive experiments on industrial datasets demonstrate that CRR effectively mitigates the identity mapping issue and achieves state-of-the-art performance in multi-class industrial anomaly detection.

1. Environments

Create a new conda environment and install required packages.

conda create -n my_env python=3.8.12
conda activate my_env
pip install -r requirements.txt

Experiments are conducted on NVIDIA GeForce RTX 3090 (24GB). Same GPU and package version are recommended.

2. Prepare Datasets

Noted that ../ is the upper directory of Dinomaly code. It is where we keep all the datasets by default. You can also alter it according to your need, just remember to modify the data_path in the code.

MVTec AD

Download the MVTec-AD dataset from URL. Unzip the file to ../mvtec_anomaly_detection.

|-- mvtec_anomaly_detection
    |-- bottle
    |-- cable
    |-- capsule
    |-- ....

VisA

Download the VisA dataset from URL. Unzip the file to ../VisA/. Preprocess the dataset to ../VisA_pytorch/ in 1-class mode by their official splitting code.

You can also run the following command for preprocess, which is the same to their official code.

python ./prepare_data/prepare_visa.py --split-type 1cls --data-folder ../VisA --save-folder ../VisA_pytorch --split-file ./prepare_data/split_csv/1cls.csv

../VisA_pytorch will be like:

|-- VisA_pytorch
    |-- 1cls
        |-- candle
            |-- ground_truth
            |-- test
                    |-- good
                    |-- bad
            |-- train
                    |-- good
        |-- capsules
        |-- ....

Real-IAD

Contact the authors of Real-IAD URL to get the net disk link.

Download and unzip realiad_1024 and realiad_jsons in ../Real-IAD. ../Real-IAD will be like:

|-- Real-IAD
    |-- realiad_1024
        |-- audiokack
        |-- bottle_cap
        |-- ....
    |-- realiad_jsons
        |-- realiad_jsons
        |-- realiad_jsons_sv
        |-- realiad_jsons_fuiad_0.0
        |-- ....

3. Run Experiments

Training Stage I

python dinomaly_realiad_uni_first.py --data_path ../Real-IAD

Training Phase II

python dinomaly_realiad_uni_second.py --data_path ../Real-IAD

Testing phase

python dinomaly_realiad_uni_test.py --data_path ../Real-IAD

Trained model weights

DatasetModelResolutionIterationsDownload
Real-IADSeg_model_7999.pthR448-C3928,000Google Drive
Real-IADdinov2_vitb14_reg4_pretrain.pthR448-C39250,000Google Drive

Results

A. Compare with MUAD SOTAs:

table1

Citation

@article{wang2025collaborative,
  title={Collaborative Reconstruction and Repair for Multi-class Industrial Anomaly Detection},
  author={Wang, Qishan and Wang, Haofeng and Gao, Shuyong and Guo, Jia and Xiong, Li and Li, Jiaqi and Bai, Dengxuan and Zhang, Wenqiang},
  journal={arXiv preprint arXiv:2512.11401},
  year={2025}
}

Acknowledge

We thank the great work Dinomaly for assisting with our work.