[ECCV 2024] An Incremental Unified Framework for Small Defect Inspection

November 16, 2024 ยท View on GitHub

[ECCV 2024] An Incremental Unified Framework for Small Defect Inspection

This is the official repository for IUF (ECCV 2024).

Jiaqi Tang, Hao Lu, Xiaogang Xu, Ruizheng Wu, Sixing Hu,

Tong Zhang, Twz Wa Cheng, Ming Ge, Ying-Cong Chen* and Fugee Tsung.

*: Corresponding Author

GitHub license made-for-VSCode Visits Badge

Here is our Project Page with Video!

๐Ÿ” Our Setting: Incremental Unified Framework (IUF)

  • ๐Ÿšฉ First framework to integrate incremental learning into the unified reconstruction-based detection.
  • ๐Ÿšฉ Overcoming memory bank capacity limitations.
  • ๐Ÿšฉ Delivering not only image-level performance but also pixel-level location.
Our Setting

๐Ÿ“ข News and Updates

  • โœ… Step 24, 2024. We release the code and dataset of IUF. Check this Google Cloud link for DOWNLOADING dataset.

โ–ถ๏ธ Getting Started

๐Ÿช’ Installation

  • PyTorch >= 1.11.0
  • Install dependencies by
    pip install -r requirements.txt
    

๐Ÿ’พ Dataset Preparation

  • Google Drive Link for DOWNLOADING dataset.

  • The dataset is organized as follows:

    โ”œโ”€โ”€ VisA
    โ”‚   โ”œโ”€โ”€ Data
    โ”‚   โ”‚   โ”œโ”€โ”€ candle
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ground_truth โ€”โ€” (bad)
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ test โ€”โ€” (Bad) (good)
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ train (good)
    โ”‚   โ”‚   โ”œโ”€โ”€ capsules
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
    โ”‚   โ”‚   โ””โ”€โ”€ ...
    โ”‚   โ”‚   
    โ”‚   โ”œโ”€โ”€ orisplit
    โ”‚   โ”‚   โ”œโ”€โ”€ candle_test.json # for testing in candle 
    โ”‚   โ”‚   โ”œโ”€โ”€ candle_test.json # for training in candle 
    โ”‚   โ”‚   โ””โ”€โ”€ ...
    |   โ”‚
    โ”‚   โ””โ”€โ”€ split
    โ”‚   โ”‚   โ”œโ”€โ”€ 8_12_train.json # for training in 8-12 class 
    โ”‚   โ”‚   โ”œโ”€โ”€ 8_test.json # for training in 1-8 class 
    โ”‚   โ”‚   โ””โ”€โ”€ 11_test.json # for training in 1-11 class 
    โ”‚
    โ”œโ”€โ”€ MvTec AD
    โ”‚   โ”œโ”€โ”€ mvtec_anomaly_detection # Data
    โ”‚   โ”œโ”€โ”€ 33333 # for 33333 class
    โ”‚   โ”œโ”€โ”€ json_test # for each class test
    โ”‚   โ”œโ”€โ”€ json_train # for each class train
    โ”‚   โ”œโ”€โ”€ test_X.json # for X class test
    โ”‚   โ”œโ”€โ”€ train_X.json  # for X class Train
    โ”‚   โ””โ”€โ”€ ...
    
  • Task Protocols: Based on the practical requirements of industrial defect inspection, we set up our experiments in both single-step and multi-step settings. We represent our task stream as Xโˆ’Yย withย Nย Step(s)\mathbf{X - Y \ with \ N \ Step(s)}. Here, X\mathbf{X} denotes the number of base objects before starting incremental learning, Y\mathbf{Y} represents the number of new objects incremented in each step, and N\mathbf{N} indicates the number of tasks during incremental learning. When training on base objects, N=0\mathbf{N} = 0, and after one step, N=N+1\mathbf{N} = \mathbf{N} + 1. Our task stream is shown as follows:

    • MVTec-AD: 14โˆ’1ย withย 1ย Step\mathbf{14-1\ with \ 1\ Step}, 10โˆ’5ย withย 1ย Step\mathbf{10-5\ with \ 1\ Step}, 3โˆ’3ย withย 4ย Steps\mathbf{3 - 3\ with \ 4\ Steps} and 10โˆ’1ย withย 5ย Steps\mathbf{10-1\ with \ 5\ Steps}.
    • VisA: 11โˆ’1ย withย 1ย Step\mathbf{11-1\ with \ 1\ Step}, 8โˆ’4ย withย 1ย Step\mathbf{8-4\ with \ 1\ Step}, 8โˆ’1ย withย 4ย Steps\mathbf{8-1\ with \ 4\ Steps}
  • Usage: follow the above protocols in incremental learning.

๐Ÿ”จ Configuration

  • The configuration files for training in experiments.

  • Dataset Setting:

      dataset:
      type: custom
    
      image_reader:
          type: opencv
          kwargs:
          image_dir: /dataset/.../VisA # for data path
          color_mode: RGB
    
      train:
          meta_file: /dataset/.../A_Data/orisplit/XX.json # for data training json path
          rebalance: False
          hflip: False
          vflip: False
          rotate: False
      
      Val:
          meta_file: /dataset/.../.../VisA/split/XX.json # for saving previous weight
    
      test:
          meta_file: /dataset/.../A_Data/orisplit/XX.json # for data testing json path
    
  • Saving Setting:

      saver:
      auto_resume: True
      always_save: True
      load_path: checkpoints/ckpt.pth.tar
      save_dir: checkpoints/
      log_dir: log/
    
  • For Testing: uncomment this part in config

    vis_compound:
       save_dir: vis_compound
       max_score: null
       min_score: null
     vis_single:
       save_dir: ./vis_single
       max_score: null
       min_score: null
    

๐Ÿ–ฅ๏ธ Training and Testing

  • Modify Dataset Setting in training configuration, then run

    sh run.sh
    

    In run.sh, it includes two stages:

    cd /dataset/.../SmallDefect_Vis/IUF
    
    # Stage 1: Training base objects
    CUDA_VISIBLE_DEVICES=0,1,2,3 python ./tools/train_val.py --config /dataset/.../SmallDefect_Vis/IUF/experiments/VisA/8_1_1_1_1/config_c1.yaml
    
    # Stage 2: Training incremental objects
    CUDA_VISIBLE_DEVICES=0,1,2,3 python ./tools/train_val.py --config /dataset/.../SmallDefect_Vis/IUF/experiments/VisA/8_1_1_1_1/config_c9.yaml
    
    CUDA_VISIBLE_DEVICES=0,1,2,3 python ./tools/train_val.py --config /dataset/.../SmallDefect_Vis/IUF/experiments/VisA/8_1_1_1_1/config_c10.yaml
    
    CUDA_VISIBLE_DEVICES=0,1,2,3 python ./tools/train_val.py --config /dataset/.../SmallDefect_Vis/IUF/experiments/VisA/8_1_1_1_1/config_c11.yaml
    
    CUDA_VISIBLE_DEVICES=0,1,2,3 python ./tools/train_val.py --config /dataset/.../SmallDefect_Vis/IUF/experiments/VisA/8_1_1_1_1/config_c12.yaml
    
    

    You can edit this to support different task protocals.

  • The logs, models and training states will be saved to ./experiments/checkpoints/... and ./experiments/logs/.... You can also use tensorboard for monitoring for the ./events_dec/....

โšก Performance

Compared with other baselines, our model achieves state-of-the-art performance:

โญ [Figure 1] Quantitative evaluation in MvTecAD.

โญ [Figure 2] Quantitative evaluation in VisA.

โญ [Figure 3] Qualitative Evaluation.

๐ŸŒ Citations

The following is a BibTeX reference:

@inproceedings{tang2024incremental,
  title = {An Incremental Unified Framework for Small Defect Inspection},
  author = {Tang, Jiaqi and Lu, Hao and Xu, Xiaogang and Wu, Ruizheng and Hu, Sixing and Zhang, Tong and Cheng, Tsz Wa and Ge, Ming and Chen, Ying-Cong and Tsung, Fugee},
  booktitle = {18th European Conference on Computer Vision (ECCV)},
  year = {2024}
}

๐Ÿ“ง Connecting with Us?

If you have any questions, please feel free to send email to jtang092@connect.hkust-gz.edu.cn.

๐Ÿ“œ Acknowledgment

The research work was sponsored by AIR@InnoHK. The code is inspired by UniAD.