abylikhsanov / Insulator-Defect-Detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Insulator-Defect-Detection

Official PyTorch Implementation of Catenary Insulator Defects Detection: A Dataset and an Unsupervised Baseline, Accepted by IEEE TIM. Framework

Datasets

Catenary Insulator Defect dataset (CID): Download from [BaiDu] [Google Drive]

Statistical Overview of CID

Train Test_Real Test_Sim Test_All
Defect-free Image 3900 0 0 33
Defect
Image
breakage 0 26 34 60
contamination 0 5 55 60
crack 0 2 58 60
dirt 0 54 6 60
missing 0 0 60 60
shelter 0 40 20 60
Total 3900 160 233 393

Some Example of CID Figure

The dataset should be placed in the 'data' folder. The training dataset should only contain defect-free samples, which should be named 'good'. The test dataset should include one category named 'good' for defect-free samples, and any other subcategories of defect samples. It should be made as follows:

data
|---- insulator
|-----|------ ground_truth
|-----|------|------ teat_all
|-----|------|------ test_real
|-----|------|------ test_sim
|-----|------ test_all
|-----|------|------ good
|-----|------|------ ...
|-----|------|------ ...
|-----|------ test_real
|-----|------|------ good
|-----|------|------ ...
|-----|------|------ ...
|-----|------ test_sim
|-----|------|------ good
|-----|------|------ ...
|-----|------|------ ...
|-----|------ train
|-----|------|------ good

Environment

This repository is implemented and tested on Python 3.9 and PyTorch 1.10. To install requirements:

pip install-r requirements.txt

Usage

To train theMAE model, run:

python train.py --batch_size 32 --epoch 2000 --model mae_vit_base_patch16 --output_dir ./checkpoints/insulator --log_dir ./checkpoints/insulator --data_path ./data/insulator --input_size 224 --blr 5e-3 --device_select 0

To evaluate and test the model, run:

for w/o pre
python inference.py --input_size=224 --mask_size=16 --test_fold="test_all" --save_dir ./results
for w/ pre
python inference_pre.py --input_size=224 --mask_size=16 --test_fold="test_real" --save_dir ./results_pre
for upper bound
python inference_ub.py --input_size=224 --mask_size=16 --test_fold="test_sim" --save_dir ./results_ub

Before running, you can download the model checkpoints directly from [BaiDu] The checkpoints should be placed in the 'checkpoints' folder. It should be made as follows:

checkpoints
|---- insulator
|-----|------ 224-10.pth
|-----|------ 224-20.pth
|-----|------ 224.txt
|-----|------ ...
|-----|------ ...
|-----|------ ...

Result

Running the code as explained in this file should achieve the following results for CID:

Defect Detection (Image AUROC, P, R, F1) and Defect Localization (Pixel AUROC, P, R, F1)

Method AUROC P R F1
Image-level
Detection
w/o pre 99.21/99.48/99.39 98.44/98.72/99.17 99.21/99.14/99.21 0.99/0.99/0.99
w/ pre 99.24/99.60/99.47 98.44/99.14/99.44 99.21/99.14/99.17 0.99/0.99/0.99
Upper Bound 100.0/100.0/100.0 100.0/100.0/100.0 100.0/100.0/100.0 1.00/1.00/1.00
Pixel-level
Localization
w/o pre 95.59/98.18/97.13 58.05/66.59/63.58 72.15/77.31/75.51 0.63/0.70/0.68
w/ pre 95.70/98.29/97.37 58.06/66.53/63.52 71.67/77.15/75.26 0.63/0.70/0.68
Upper Bound 96.94/99.49/98.59 59.38/68.73/65.42 75.20/79.34/77.90 0.65/0.73/0.70

Visualization examples

Result

Acknowledgement

We use some codes from repositories including MAE

License

This project is under the MIT license. See LICENSE for details.

About

License:MIT License


Languages

Language:Python 100.0%