Skip to content

Commit 8a2dc77

Browse files
committed
alpha version
1 parent e149f57 commit 8a2dc77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3061
-2
lines changed

README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1-
# Unsupervised-Defect-Segmentation
2-
Unsupervised-Defect-Segmentation anomaly detection
1+
# DeeCamp-10Group-Unsupervised-Defect-Segmentation
2+
3+
# Abstract
4+
Deep learning is well established in the mainstream of computer vision, but it relies on large amounts of data.
5+
especially in the industrial field, such as product surface defect detection task. Mainstream neural networks framework
6+
(detection, semantic segmentation) must have defect samples (all defect types to be detected) for training, and the number
7+
of defect samples should not be too small. Although defect learning is relatively easy, heavy defect collection and labeling
8+
work is introduced. Moreover, in some production processes in the industrial field, it is difficult to provide sufficient
9+
defect samples for training with a low defect rate, and it is difficult to meet the 'data-hungry deep'learning model.In contrast,
10+
there are plenty of positive samples in industrial production that have no defects at all. We use this characteristic
11+
of industrial production to gain the ability to detect bad samples by learning only good samples. This defect detection technology
12+
based on positive samples can be applied to AI at low cost in more and more complex industrial scenarios, so it has great practical significance.
13+
14+
# Introduction
15+
In this work, we focus on unsupervised defect segmentation for visual inspection.
16+
The goal is to segment defective regions in images after having trained exclusively on
17+
non-defective samples. It has been shown that architectures based on convolutional neural networks (CNNs) such
18+
as autoencoders or generative adversarial networks can be used for this task.
19+
The input picture x into the autoencoder or GAN, get the restored image y.
20+
Then compare the features of each pixel of x and y, where the feature difference between x and y is large, that is
21+
the defect.
22+
23+
# Architecture
24+
![architecture](doc/architecture.jpg)
25+
26+
# Directory
27+
- `/config`: This repo includes configuration file for training and evaluation. The parameters are saved in `.jason` file.
28+
- `/db`: This repo includes codes of data set tools
29+
- `/model`: Our networks codes are in `model/netwroks` and segmentation codes are in `mode/segmentation`.
30+
- `/tools`: This repo includes codes of auxiliary function just like timer, log writer and so on.

config/RED_Net_2skips-grid.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "RED_Net_2skips",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 1,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "Multi_SSIM_loss",
11+
"window_size":[3, 7, 15],
12+
13+
"start_epoch": 0,
14+
"max_epoch": 200,
15+
"snapshot": 10,
16+
"learning_rate": 1e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [90, 150, 200]
19+
},
20+
"db": {
21+
"name": "chip",
22+
"data_dir": "D:/DataSet/chip_grid",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [768, 768],
29+
"batch_size": 2
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/RED_Net_2skips-mvtec.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "RED_Net_2skips",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 3,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "SSIM_loss",
11+
"window_size":11,
12+
13+
"start_epoch": 0,
14+
"max_epoch": 200,
15+
"snapshot": 10,
16+
"learning_rate": 4e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [150, 200]
19+
},
20+
"db": {
21+
"name": "mvtec",
22+
"data_dir": "D:/DataSet/mvtec_anomaly_detection",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": false,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [256, 256],
29+
"batch_size": 16
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/RED_Net_3skips-grid.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "RED_Net_3skips",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 1,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "Multi_SSIM_loss",
11+
"window_size":[3, 7, 15],
12+
13+
"start_epoch": 0,
14+
"max_epoch": 100,
15+
"snapshot": 10,
16+
"learning_rate": 1e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [60, 100]
19+
},
20+
"db": {
21+
"name": "chip",
22+
"data_dir": "D:/DataSet/chip_grid",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [768, 768],
29+
"batch_size": 32
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/RED_Net_3skips-mvtec.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "RED_Net_3skips",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 3,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "SSIM_loss",
11+
"window_size":11,
12+
13+
"start_epoch": 0,
14+
"max_epoch": 200,
15+
"snapshot": 10,
16+
"learning_rate": 4e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [150, 200]
19+
},
20+
"db": {
21+
"name": "mvtec",
22+
"data_dir": "D:/DataSet/mvtec_anomaly_detection",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [256, 256],
29+
"batch_size": 16
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/RED_Net_4skips-mvtec.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "RED_Net_4skips",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 3,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "SSIM_loss",
11+
"window_size":11,
12+
13+
"start_epoch": 0,
14+
"max_epoch": 200,
15+
"snapshot": 10,
16+
"learning_rate": 4e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [150, 200]
19+
},
20+
"db": {
21+
"name": "mvtec",
22+
"data_dir": "D:/DataSet/mvtec_anomaly_detection",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [256, 256],
29+
"batch_size": 16
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/SRGAN-mvtec.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "SRGAN",
4+
"type": "GAN",
5+
"code_dim": 256,
6+
"img_channel": 3,
7+
"upscale_factor":4,
8+
"fp16": false
9+
},
10+
"op": {
11+
"loss": "SRGAN_loss",
12+
"vgg16_weight_path": "./weights/vgg16_reducedfc.pth",
13+
"start_epoch": 0,
14+
"max_epoch": 120,
15+
"snapshot": 10,
16+
"learning_rate": 5e-4,
17+
"decay_rate": 10,
18+
"epoch_steps": [60, 120]
19+
},
20+
"db": {
21+
"name": "mvtec",
22+
"data_dir": "D:/DataSet/mvtec_anomaly_detection",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [256, 256],
29+
"batch_size": 2
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/SSIM-mvtec.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "SSIM_Net",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"img_channel": 3,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "Multi_SSIM_loss",
11+
"window_size":[3, 7, 15],
12+
13+
"start_epoch": 0,
14+
"max_epoch": 120,
15+
"snapshot": 10,
16+
"learning_rate": 1e-3,
17+
"decay_rate": 10,
18+
"epoch_steps": [50, 120]
19+
},
20+
"db": {
21+
"name": "mvtec",
22+
"data_dir": "D:/DataSet/mvtec_anomaly_detection",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"use_validation_set": true,
26+
"validation_split": "validation",
27+
"val_split": "test",
28+
"resize": [256, 256],
29+
"batch_size": 2
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/SSIM_lite-chip.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"model": {
3+
"name": "SSIM_Net_lite",
4+
"type": "Encoder",
5+
"code_dim": 128,
6+
"img_channel": 1,
7+
"fp16": false
8+
},
9+
"op": {
10+
"loss": "SSIM_loss",
11+
"window_size":11,
12+
13+
"start_epoch": 0,
14+
"max_epoch": 100,
15+
"snapshot": 10,
16+
"learning_rate": 5e-4,
17+
"decay_rate": 10,
18+
"epoch_steps": [95, 100]
19+
},
20+
"db": {
21+
"name": "chip",
22+
"data_dir": "D:/DataSet/chip_cell",
23+
"loader_threads": 4,
24+
"train_split": "train",
25+
"val_split": "test",
26+
"resize": [256, 256],
27+
"batch_size": 16
28+
},
29+
"system": {
30+
"resume": false,
31+
"resume_path": "",
32+
"finetune": false,
33+
"finetune_path": "",
34+
"save_dir": "./weights/"
35+
}
36+
}

config/VAE.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"model": {
3+
"name": "VAE_Net0",
4+
"type": "Encoder",
5+
"code_dim": 256,
6+
"fp16": false
7+
},
8+
"op": {
9+
"loss": "VAE_loss",
10+
"window_size":11,
11+
12+
"start_epoch": 0,
13+
"max_epoch": 200,
14+
"snapshot": 4,
15+
"learning_rate": 1e-4,
16+
"decay_rate": 10,
17+
"epoch_steps": [150, 200]
18+
},
19+
"db": {
20+
"name": "mvtec",
21+
"data_dir": "/home/yangxusheng/Desktop/baimingliang/torch-minist/mvtec_anomaly_detection",
22+
"loader_threads": 4,
23+
"train_split": "train",
24+
"use_validation_set": true,
25+
"validation_split": "validation",
26+
"val_split": "test",
27+
"resize": [256, 256],
28+
"crop_size": [128, 128],
29+
"batch_size": 16
30+
},
31+
"system": {
32+
"resume": false,
33+
"resume_path": "",
34+
"finetune": false,
35+
"finetune_path": "",
36+
"save_dir": "./weights/"
37+
}
38+
}

config/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)