-
Notifications
You must be signed in to change notification settings - Fork 9
/
realnet.yaml
157 lines (136 loc) · 2.9 KB
/
realnet.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
version: v1.0.0
random_seed: 100
dataset:
type: mvtec
image_reader:
type: opencv
kwargs:
image_dir: data/MVTec-AD/mvtec/
color_mode: RGB
train:
meta_file: data/MVTec-AD/samples/train_{}.json
dtd_dir: data/DTD/images
sdas_dir: data/MVTec-AD/sdas/{}
dtd_transparency_range: [0.2, 1.0]
sdas_transparency_range: [0.5, 1.0]
perlin_scale: 6
min_perlin_scale: 0
hflip: False
vflip: False
rotate: False
# use SDAS only
anomaly_types:
normal: 0.5
sdas: 0.5
# use DTD only
# anomaly_types:
# normal: 0.5
# dtd: 0.5
# use both SDAS and DTD
# anomaly_types:
# normal: 0.5
# dtd: 0.25
# sdas: 0.25
test:
meta_file: ./data/MVTec-AD/samples/test_{}.json
input_size: [256,256]
pixel_mean: [0.485, 0.456, 0.406]
pixel_std: [0.229, 0.224, 0.225]
batch_size: 16
workers: 4
structure:
- name: block1
layers:
- idx: layer1
planes: 256
stride: 4
- name: block2
layers:
- idx: layer2
planes: 512
stride: 8
- name: block3
layers:
- idx: layer3
planes: 512
stride: 16
- name: block4
layers:
- idx: layer4
planes: 256
stride: 32
# architecture C in paper, training requires 32GB GPU memory.
#structure:
# - name: block1
# layers:
# - idx: layer1
# planes: 256
# - idx: layer2
# planes: 512
# stride: 4
#
# - name: block2
# layers:
# - idx: layer3
# planes: 512
# - idx: layer4
# planes: 256
# stride: 16
net:
- name: backbone
type: models.backbones.Backbone
frozen: True
kwargs:
backbone: wide_resnet50_2
- name: afs
type: models.afs.AFS
frozen: True
prev: backbone
kwargs:
init_bsn: 64
- name: recon
type: models.recon.ReconstructionLayer
prev: afs
kwargs:
num_res_blocks: 2
hide_channels_ratio: 0.5
channel_mult: [1,2,4]
attention_mult: [2,4]
- name: rrs
type: models.rrs.RRS
prev: recon
kwargs:
modes: [max,mean]
mode_numbers: [256,256] # dimensions of RRS, max=256,mean=256
num_residual_layers: 2
stop_grad: False
trainer:
max_epoch: 1000
val_freq_epoch: 5
print_freq_step: 20
optimizer:
type: Adam
kwargs:
lr: 0.0001
betas: [0.9, 0.999]
saver:
checkpoints_dir: realnet_checkpoints/
log_dir: realnet_log/
vis_dir: realnet_vis/
criterion:
- name: SegmentCrossEntropyLoss
type: SegmentCrossEntropyLoss
kwargs:
weight: 1.0
- name: FeatureMSELoss
type: FeatureMSELoss
kwargs:
weight: 1.0
evaluator:
key_metric: mean
metrics:
auc:
- name: image
kwargs:
avgpool_size: [16, 16]
- name: pixel