Spaces:
Runtime error
Runtime error
faceplugin
commited on
Commit
•
0e1e06d
1
Parent(s):
e74eb3a
Clean code
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- app.py +4 -4
- face_recognition1/face_detect/checkpoints/FaceBoxesProd.pth +0 -3
- face_recognition1/face_detect/checkpoints/Widerface-RetinaFace.caffemodel +0 -3
- face_recognition1/face_detect/checkpoints/deploy.prototxt +0 -2499
- face_recognition1/face_detect/data/config.py +0 -14
- face_recognition1/face_detect/layers/__init__.py +0 -2
- face_recognition1/face_detect/layers/functions/prior_box.py +0 -43
- face_recognition1/face_detect/layers/modules/__init__.py +0 -3
- face_recognition1/face_detect/layers/modules/multibox_loss.py +0 -108
- face_recognition1/face_detect/models/__init__.py +0 -0
- face_recognition1/face_detect/models/faceboxes.py +0 -149
- face_recognition1/face_detect/models/voc-model-labels.txt +0 -2
- face_recognition1/face_detect/test.py +0 -197
- face_recognition1/face_detect/utils/__init__.py +0 -0
- face_recognition1/face_detect/utils/box_utils.py +0 -276
- face_recognition1/face_detect/utils/build.py +0 -138
- face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/cpu_nms.o +0 -0
- face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/gpu_nms.o +0 -0
- face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/nms_kernel.o +0 -0
- face_recognition1/face_detect/utils/nms/cpu_nms.c +0 -0
- face_recognition1/face_detect/utils/nms/cpu_nms.cpython-36m-x86_64-linux-gnu.so +0 -0
- face_recognition1/face_detect/utils/nms/cpu_nms.pyx +0 -156
- face_recognition1/face_detect/utils/nms/gpu_nms.cpp +0 -0
- face_recognition1/face_detect/utils/nms/gpu_nms.cpython-36m-x86_64-linux-gnu.so +0 -0
- face_recognition1/face_detect/utils/nms/gpu_nms.hpp +0 -2
- face_recognition1/face_detect/utils/nms/gpu_nms.pyx +0 -24
- face_recognition1/face_detect/utils/nms/nms_kernel.cu +0 -144
- face_recognition1/face_detect/utils/nms/py_cpu_nms.py +0 -32
- face_recognition1/face_detect/utils/nms_wrapper.py +0 -29
- face_recognition1/face_detect/utils/timer.py +0 -33
- face_recognition1/face_feature/__init__.py +0 -0
- face_recognition1/face_feature/checkpoints/feat_net.ckpt +0 -3
- face_recognition1/face_feature/dataloader/__init__.py +0 -7
- face_recognition1/face_feature/dataloader/agedb.py +0 -88
- face_recognition1/face_feature/dataloader/casia_webface.py +0 -124
- face_recognition1/face_feature/dataloader/cfp.py +0 -88
- face_recognition1/face_feature/dataloader/lfw.py +0 -141
- face_recognition1/face_feature/dataloader/lfw_2.py +0 -88
- face_recognition1/face_feature/dataloader/megaface.py +0 -81
- face_recognition1/face_feature/datasets/__init__.py +0 -0
- face_recognition1/face_feature/datasets/prepare_dataset.py +0 -111
- face_recognition1/face_feature/eval_agedb30.py +0 -146
- face_recognition1/face_feature/eval_cfp.py +0 -143
- face_recognition1/face_feature/eval_deepglint_merge.py +0 -101
- face_recognition1/face_feature/eval_lfw.py +0 -195
- face_recognition1/face_feature/eval_lfw_blufr.py +0 -63
- face_recognition1/face_feature/eval_megaface.py +0 -114
- face_recognition1/face_feature/log.log +0 -0
- face_recognition1/face_feature/loss/__init__.py +0 -7
- face_recognition1/face_feature/loss/agentcenterloss.py +0 -42
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import sys
|
2 |
sys.path.append('.')
|
3 |
-
sys.path.append('./
|
4 |
import os
|
5 |
import io
|
6 |
import cv2
|
@@ -14,15 +14,15 @@ import configparser
|
|
14 |
import numpy as np
|
15 |
from PIL import Image
|
16 |
|
17 |
-
|
18 |
-
from face_recognition1.run import match_image
|
19 |
|
20 |
|
21 |
def face_recognition_on_file(file1, file2):
|
22 |
img1 = cv2.imread(file1)
|
23 |
img2 = cv2.imread(file2)
|
24 |
|
25 |
-
response =
|
26 |
|
27 |
return response
|
28 |
|
|
|
1 |
import sys
|
2 |
sys.path.append('.')
|
3 |
+
sys.path.append('./face_recognition')
|
4 |
import os
|
5 |
import io
|
6 |
import cv2
|
|
|
14 |
import numpy as np
|
15 |
from PIL import Image
|
16 |
|
17 |
+
from face_recognition.match import match_1_1
|
18 |
+
# from face_recognition1.run import match_image
|
19 |
|
20 |
|
21 |
def face_recognition_on_file(file1, file2):
|
22 |
img1 = cv2.imread(file1)
|
23 |
img2 = cv2.imread(file2)
|
24 |
|
25 |
+
response = match_1_1(img1, img2)
|
26 |
|
27 |
return response
|
28 |
|
face_recognition1/face_detect/checkpoints/FaceBoxesProd.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:c0cb2b1e40710c0aa5fc32a8759b1496a0fe0a126c907ca0ffe35b4bd0709d09
|
3 |
-
size 4072492
|
|
|
|
|
|
|
|
face_recognition1/face_detect/checkpoints/Widerface-RetinaFace.caffemodel
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:d08338a2c207df16a9c566f767fea67fb43ba6fff76ce11e938fe3fabefb9402
|
3 |
-
size 1866013
|
|
|
|
|
|
|
|
face_recognition1/face_detect/checkpoints/deploy.prototxt
DELETED
@@ -1,2499 +0,0 @@
|
|
1 |
-
name: "20200403141819_Widerface-RetinaFace_mb_640_negscope-0_epoch_4"
|
2 |
-
input: "data"
|
3 |
-
input_dim: 1
|
4 |
-
input_dim: 3
|
5 |
-
input_dim: 640
|
6 |
-
input_dim: 640
|
7 |
-
layer {
|
8 |
-
name: "conv1"
|
9 |
-
type: "Convolution"
|
10 |
-
bottom: "data"
|
11 |
-
top: "conv_blob1"
|
12 |
-
convolution_param {
|
13 |
-
num_output: 8
|
14 |
-
bias_term: false
|
15 |
-
pad: 1
|
16 |
-
kernel_size: 3
|
17 |
-
group: 1
|
18 |
-
stride: 2
|
19 |
-
weight_filler {
|
20 |
-
type: "xavier"
|
21 |
-
}
|
22 |
-
dilation: 1
|
23 |
-
}
|
24 |
-
}
|
25 |
-
layer {
|
26 |
-
name: "batch_norm1"
|
27 |
-
type: "BatchNorm"
|
28 |
-
bottom: "conv_blob1"
|
29 |
-
top: "batch_norm_blob1"
|
30 |
-
batch_norm_param {
|
31 |
-
use_global_stats: true
|
32 |
-
eps: 9.9999997e-06
|
33 |
-
}
|
34 |
-
}
|
35 |
-
layer {
|
36 |
-
name: "bn_scale1"
|
37 |
-
type: "Scale"
|
38 |
-
bottom: "batch_norm_blob1"
|
39 |
-
top: "batch_norm_blob1"
|
40 |
-
scale_param {
|
41 |
-
bias_term: true
|
42 |
-
}
|
43 |
-
}
|
44 |
-
layer {
|
45 |
-
name: "relu1"
|
46 |
-
type: "ReLU"
|
47 |
-
bottom: "batch_norm_blob1"
|
48 |
-
top: "relu_blob1"
|
49 |
-
}
|
50 |
-
layer {
|
51 |
-
name: "conv2"
|
52 |
-
type: "Convolution"
|
53 |
-
bottom: "relu_blob1"
|
54 |
-
top: "conv_blob2"
|
55 |
-
convolution_param {
|
56 |
-
num_output: 8
|
57 |
-
bias_term: false
|
58 |
-
pad: 1
|
59 |
-
kernel_size: 3
|
60 |
-
group: 8
|
61 |
-
stride: 1
|
62 |
-
weight_filler {
|
63 |
-
type: "xavier"
|
64 |
-
}
|
65 |
-
dilation: 1
|
66 |
-
}
|
67 |
-
}
|
68 |
-
layer {
|
69 |
-
name: "batch_norm2"
|
70 |
-
type: "BatchNorm"
|
71 |
-
bottom: "conv_blob2"
|
72 |
-
top: "batch_norm_blob2"
|
73 |
-
batch_norm_param {
|
74 |
-
use_global_stats: true
|
75 |
-
eps: 9.9999997e-06
|
76 |
-
}
|
77 |
-
}
|
78 |
-
layer {
|
79 |
-
name: "bn_scale2"
|
80 |
-
type: "Scale"
|
81 |
-
bottom: "batch_norm_blob2"
|
82 |
-
top: "batch_norm_blob2"
|
83 |
-
scale_param {
|
84 |
-
bias_term: true
|
85 |
-
}
|
86 |
-
}
|
87 |
-
layer {
|
88 |
-
name: "relu2"
|
89 |
-
type: "ReLU"
|
90 |
-
bottom: "batch_norm_blob2"
|
91 |
-
top: "relu_blob2"
|
92 |
-
}
|
93 |
-
layer {
|
94 |
-
name: "conv3"
|
95 |
-
type: "Convolution"
|
96 |
-
bottom: "relu_blob2"
|
97 |
-
top: "conv_blob3"
|
98 |
-
convolution_param {
|
99 |
-
num_output: 16
|
100 |
-
bias_term: false
|
101 |
-
pad: 0
|
102 |
-
kernel_size: 1
|
103 |
-
group: 1
|
104 |
-
stride: 1
|
105 |
-
weight_filler {
|
106 |
-
type: "xavier"
|
107 |
-
}
|
108 |
-
dilation: 1
|
109 |
-
}
|
110 |
-
}
|
111 |
-
layer {
|
112 |
-
name: "batch_norm3"
|
113 |
-
type: "BatchNorm"
|
114 |
-
bottom: "conv_blob3"
|
115 |
-
top: "batch_norm_blob3"
|
116 |
-
batch_norm_param {
|
117 |
-
use_global_stats: true
|
118 |
-
eps: 9.9999997e-06
|
119 |
-
}
|
120 |
-
}
|
121 |
-
layer {
|
122 |
-
name: "bn_scale3"
|
123 |
-
type: "Scale"
|
124 |
-
bottom: "batch_norm_blob3"
|
125 |
-
top: "batch_norm_blob3"
|
126 |
-
scale_param {
|
127 |
-
bias_term: true
|
128 |
-
}
|
129 |
-
}
|
130 |
-
layer {
|
131 |
-
name: "relu3"
|
132 |
-
type: "ReLU"
|
133 |
-
bottom: "batch_norm_blob3"
|
134 |
-
top: "relu_blob3"
|
135 |
-
}
|
136 |
-
layer {
|
137 |
-
name: "conv4"
|
138 |
-
type: "Convolution"
|
139 |
-
bottom: "relu_blob3"
|
140 |
-
top: "conv_blob4"
|
141 |
-
convolution_param {
|
142 |
-
num_output: 16
|
143 |
-
bias_term: false
|
144 |
-
pad: 1
|
145 |
-
kernel_size: 3
|
146 |
-
group: 16
|
147 |
-
stride: 2
|
148 |
-
weight_filler {
|
149 |
-
type: "xavier"
|
150 |
-
}
|
151 |
-
dilation: 1
|
152 |
-
}
|
153 |
-
}
|
154 |
-
layer {
|
155 |
-
name: "batch_norm4"
|
156 |
-
type: "BatchNorm"
|
157 |
-
bottom: "conv_blob4"
|
158 |
-
top: "batch_norm_blob4"
|
159 |
-
batch_norm_param {
|
160 |
-
use_global_stats: true
|
161 |
-
eps: 9.9999997e-06
|
162 |
-
}
|
163 |
-
}
|
164 |
-
layer {
|
165 |
-
name: "bn_scale4"
|
166 |
-
type: "Scale"
|
167 |
-
bottom: "batch_norm_blob4"
|
168 |
-
top: "batch_norm_blob4"
|
169 |
-
scale_param {
|
170 |
-
bias_term: true
|
171 |
-
}
|
172 |
-
}
|
173 |
-
layer {
|
174 |
-
name: "relu4"
|
175 |
-
type: "ReLU"
|
176 |
-
bottom: "batch_norm_blob4"
|
177 |
-
top: "relu_blob4"
|
178 |
-
}
|
179 |
-
layer {
|
180 |
-
name: "conv5"
|
181 |
-
type: "Convolution"
|
182 |
-
bottom: "relu_blob4"
|
183 |
-
top: "conv_blob5"
|
184 |
-
convolution_param {
|
185 |
-
num_output: 32
|
186 |
-
bias_term: false
|
187 |
-
pad: 0
|
188 |
-
kernel_size: 1
|
189 |
-
group: 1
|
190 |
-
stride: 1
|
191 |
-
weight_filler {
|
192 |
-
type: "xavier"
|
193 |
-
}
|
194 |
-
dilation: 1
|
195 |
-
}
|
196 |
-
}
|
197 |
-
layer {
|
198 |
-
name: "batch_norm5"
|
199 |
-
type: "BatchNorm"
|
200 |
-
bottom: "conv_blob5"
|
201 |
-
top: "batch_norm_blob5"
|
202 |
-
batch_norm_param {
|
203 |
-
use_global_stats: true
|
204 |
-
eps: 9.9999997e-06
|
205 |
-
}
|
206 |
-
}
|
207 |
-
layer {
|
208 |
-
name: "bn_scale5"
|
209 |
-
type: "Scale"
|
210 |
-
bottom: "batch_norm_blob5"
|
211 |
-
top: "batch_norm_blob5"
|
212 |
-
scale_param {
|
213 |
-
bias_term: true
|
214 |
-
}
|
215 |
-
}
|
216 |
-
layer {
|
217 |
-
name: "relu5"
|
218 |
-
type: "ReLU"
|
219 |
-
bottom: "batch_norm_blob5"
|
220 |
-
top: "relu_blob5"
|
221 |
-
}
|
222 |
-
layer {
|
223 |
-
name: "conv6"
|
224 |
-
type: "Convolution"
|
225 |
-
bottom: "relu_blob5"
|
226 |
-
top: "conv_blob6"
|
227 |
-
convolution_param {
|
228 |
-
num_output: 32
|
229 |
-
bias_term: false
|
230 |
-
pad: 1
|
231 |
-
kernel_size: 3
|
232 |
-
group: 32
|
233 |
-
stride: 1
|
234 |
-
weight_filler {
|
235 |
-
type: "xavier"
|
236 |
-
}
|
237 |
-
dilation: 1
|
238 |
-
}
|
239 |
-
}
|
240 |
-
layer {
|
241 |
-
name: "batch_norm6"
|
242 |
-
type: "BatchNorm"
|
243 |
-
bottom: "conv_blob6"
|
244 |
-
top: "batch_norm_blob6"
|
245 |
-
batch_norm_param {
|
246 |
-
use_global_stats: true
|
247 |
-
eps: 9.9999997e-06
|
248 |
-
}
|
249 |
-
}
|
250 |
-
layer {
|
251 |
-
name: "bn_scale6"
|
252 |
-
type: "Scale"
|
253 |
-
bottom: "batch_norm_blob6"
|
254 |
-
top: "batch_norm_blob6"
|
255 |
-
scale_param {
|
256 |
-
bias_term: true
|
257 |
-
}
|
258 |
-
}
|
259 |
-
layer {
|
260 |
-
name: "relu6"
|
261 |
-
type: "ReLU"
|
262 |
-
bottom: "batch_norm_blob6"
|
263 |
-
top: "relu_blob6"
|
264 |
-
}
|
265 |
-
layer {
|
266 |
-
name: "conv7"
|
267 |
-
type: "Convolution"
|
268 |
-
bottom: "relu_blob6"
|
269 |
-
top: "conv_blob7"
|
270 |
-
convolution_param {
|
271 |
-
num_output: 32
|
272 |
-
bias_term: false
|
273 |
-
pad: 0
|
274 |
-
kernel_size: 1
|
275 |
-
group: 1
|
276 |
-
stride: 1
|
277 |
-
weight_filler {
|
278 |
-
type: "xavier"
|
279 |
-
}
|
280 |
-
dilation: 1
|
281 |
-
}
|
282 |
-
}
|
283 |
-
layer {
|
284 |
-
name: "batch_norm7"
|
285 |
-
type: "BatchNorm"
|
286 |
-
bottom: "conv_blob7"
|
287 |
-
top: "batch_norm_blob7"
|
288 |
-
batch_norm_param {
|
289 |
-
use_global_stats: true
|
290 |
-
eps: 9.9999997e-06
|
291 |
-
}
|
292 |
-
}
|
293 |
-
layer {
|
294 |
-
name: "bn_scale7"
|
295 |
-
type: "Scale"
|
296 |
-
bottom: "batch_norm_blob7"
|
297 |
-
top: "batch_norm_blob7"
|
298 |
-
scale_param {
|
299 |
-
bias_term: true
|
300 |
-
}
|
301 |
-
}
|
302 |
-
layer {
|
303 |
-
name: "relu7"
|
304 |
-
type: "ReLU"
|
305 |
-
bottom: "batch_norm_blob7"
|
306 |
-
top: "relu_blob7"
|
307 |
-
}
|
308 |
-
layer {
|
309 |
-
name: "conv8"
|
310 |
-
type: "Convolution"
|
311 |
-
bottom: "relu_blob7"
|
312 |
-
top: "conv_blob8"
|
313 |
-
convolution_param {
|
314 |
-
num_output: 32
|
315 |
-
bias_term: false
|
316 |
-
pad: 1
|
317 |
-
kernel_size: 3
|
318 |
-
group: 32
|
319 |
-
stride: 2
|
320 |
-
weight_filler {
|
321 |
-
type: "xavier"
|
322 |
-
}
|
323 |
-
dilation: 1
|
324 |
-
}
|
325 |
-
}
|
326 |
-
layer {
|
327 |
-
name: "batch_norm8"
|
328 |
-
type: "BatchNorm"
|
329 |
-
bottom: "conv_blob8"
|
330 |
-
top: "batch_norm_blob8"
|
331 |
-
batch_norm_param {
|
332 |
-
use_global_stats: true
|
333 |
-
eps: 9.9999997e-06
|
334 |
-
}
|
335 |
-
}
|
336 |
-
layer {
|
337 |
-
name: "bn_scale8"
|
338 |
-
type: "Scale"
|
339 |
-
bottom: "batch_norm_blob8"
|
340 |
-
top: "batch_norm_blob8"
|
341 |
-
scale_param {
|
342 |
-
bias_term: true
|
343 |
-
}
|
344 |
-
}
|
345 |
-
layer {
|
346 |
-
name: "relu8"
|
347 |
-
type: "ReLU"
|
348 |
-
bottom: "batch_norm_blob8"
|
349 |
-
top: "relu_blob8"
|
350 |
-
}
|
351 |
-
layer {
|
352 |
-
name: "conv9"
|
353 |
-
type: "Convolution"
|
354 |
-
bottom: "relu_blob8"
|
355 |
-
top: "conv_blob9"
|
356 |
-
convolution_param {
|
357 |
-
num_output: 64
|
358 |
-
bias_term: false
|
359 |
-
pad: 0
|
360 |
-
kernel_size: 1
|
361 |
-
group: 1
|
362 |
-
stride: 1
|
363 |
-
weight_filler {
|
364 |
-
type: "xavier"
|
365 |
-
}
|
366 |
-
dilation: 1
|
367 |
-
}
|
368 |
-
}
|
369 |
-
layer {
|
370 |
-
name: "batch_norm9"
|
371 |
-
type: "BatchNorm"
|
372 |
-
bottom: "conv_blob9"
|
373 |
-
top: "batch_norm_blob9"
|
374 |
-
batch_norm_param {
|
375 |
-
use_global_stats: true
|
376 |
-
eps: 9.9999997e-06
|
377 |
-
}
|
378 |
-
}
|
379 |
-
layer {
|
380 |
-
name: "bn_scale9"
|
381 |
-
type: "Scale"
|
382 |
-
bottom: "batch_norm_blob9"
|
383 |
-
top: "batch_norm_blob9"
|
384 |
-
scale_param {
|
385 |
-
bias_term: true
|
386 |
-
}
|
387 |
-
}
|
388 |
-
layer {
|
389 |
-
name: "relu9"
|
390 |
-
type: "ReLU"
|
391 |
-
bottom: "batch_norm_blob9"
|
392 |
-
top: "relu_blob9"
|
393 |
-
}
|
394 |
-
layer {
|
395 |
-
name: "conv10"
|
396 |
-
type: "Convolution"
|
397 |
-
bottom: "relu_blob9"
|
398 |
-
top: "conv_blob10"
|
399 |
-
convolution_param {
|
400 |
-
num_output: 64
|
401 |
-
bias_term: false
|
402 |
-
pad: 1
|
403 |
-
kernel_size: 3
|
404 |
-
group: 64
|
405 |
-
stride: 1
|
406 |
-
weight_filler {
|
407 |
-
type: "xavier"
|
408 |
-
}
|
409 |
-
dilation: 1
|
410 |
-
}
|
411 |
-
}
|
412 |
-
layer {
|
413 |
-
name: "batch_norm10"
|
414 |
-
type: "BatchNorm"
|
415 |
-
bottom: "conv_blob10"
|
416 |
-
top: "batch_norm_blob10"
|
417 |
-
batch_norm_param {
|
418 |
-
use_global_stats: true
|
419 |
-
eps: 9.9999997e-06
|
420 |
-
}
|
421 |
-
}
|
422 |
-
layer {
|
423 |
-
name: "bn_scale10"
|
424 |
-
type: "Scale"
|
425 |
-
bottom: "batch_norm_blob10"
|
426 |
-
top: "batch_norm_blob10"
|
427 |
-
scale_param {
|
428 |
-
bias_term: true
|
429 |
-
}
|
430 |
-
}
|
431 |
-
layer {
|
432 |
-
name: "relu10"
|
433 |
-
type: "ReLU"
|
434 |
-
bottom: "batch_norm_blob10"
|
435 |
-
top: "relu_blob10"
|
436 |
-
}
|
437 |
-
layer {
|
438 |
-
name: "conv11"
|
439 |
-
type: "Convolution"
|
440 |
-
bottom: "relu_blob10"
|
441 |
-
top: "conv_blob11"
|
442 |
-
convolution_param {
|
443 |
-
num_output: 64
|
444 |
-
bias_term: false
|
445 |
-
pad: 0
|
446 |
-
kernel_size: 1
|
447 |
-
group: 1
|
448 |
-
stride: 1
|
449 |
-
weight_filler {
|
450 |
-
type: "xavier"
|
451 |
-
}
|
452 |
-
dilation: 1
|
453 |
-
}
|
454 |
-
}
|
455 |
-
layer {
|
456 |
-
name: "batch_norm11"
|
457 |
-
type: "BatchNorm"
|
458 |
-
bottom: "conv_blob11"
|
459 |
-
top: "batch_norm_blob11"
|
460 |
-
batch_norm_param {
|
461 |
-
use_global_stats: true
|
462 |
-
eps: 9.9999997e-06
|
463 |
-
}
|
464 |
-
}
|
465 |
-
layer {
|
466 |
-
name: "bn_scale11"
|
467 |
-
type: "Scale"
|
468 |
-
bottom: "batch_norm_blob11"
|
469 |
-
top: "batch_norm_blob11"
|
470 |
-
scale_param {
|
471 |
-
bias_term: true
|
472 |
-
}
|
473 |
-
}
|
474 |
-
layer {
|
475 |
-
name: "relu11"
|
476 |
-
type: "ReLU"
|
477 |
-
bottom: "batch_norm_blob11"
|
478 |
-
top: "relu_blob11"
|
479 |
-
}
|
480 |
-
layer {
|
481 |
-
name: "conv12"
|
482 |
-
type: "Convolution"
|
483 |
-
bottom: "relu_blob11"
|
484 |
-
top: "conv_blob12"
|
485 |
-
convolution_param {
|
486 |
-
num_output: 64
|
487 |
-
bias_term: false
|
488 |
-
pad: 1
|
489 |
-
kernel_size: 3
|
490 |
-
group: 64
|
491 |
-
stride: 2
|
492 |
-
weight_filler {
|
493 |
-
type: "xavier"
|
494 |
-
}
|
495 |
-
dilation: 1
|
496 |
-
}
|
497 |
-
}
|
498 |
-
layer {
|
499 |
-
name: "batch_norm12"
|
500 |
-
type: "BatchNorm"
|
501 |
-
bottom: "conv_blob12"
|
502 |
-
top: "batch_norm_blob12"
|
503 |
-
batch_norm_param {
|
504 |
-
use_global_stats: true
|
505 |
-
eps: 9.9999997e-06
|
506 |
-
}
|
507 |
-
}
|
508 |
-
layer {
|
509 |
-
name: "bn_scale12"
|
510 |
-
type: "Scale"
|
511 |
-
bottom: "batch_norm_blob12"
|
512 |
-
top: "batch_norm_blob12"
|
513 |
-
scale_param {
|
514 |
-
bias_term: true
|
515 |
-
}
|
516 |
-
}
|
517 |
-
layer {
|
518 |
-
name: "relu12"
|
519 |
-
type: "ReLU"
|
520 |
-
bottom: "batch_norm_blob12"
|
521 |
-
top: "relu_blob12"
|
522 |
-
}
|
523 |
-
layer {
|
524 |
-
name: "conv13"
|
525 |
-
type: "Convolution"
|
526 |
-
bottom: "relu_blob12"
|
527 |
-
top: "conv_blob13"
|
528 |
-
convolution_param {
|
529 |
-
num_output: 128
|
530 |
-
bias_term: false
|
531 |
-
pad: 0
|
532 |
-
kernel_size: 1
|
533 |
-
group: 1
|
534 |
-
stride: 1
|
535 |
-
weight_filler {
|
536 |
-
type: "xavier"
|
537 |
-
}
|
538 |
-
dilation: 1
|
539 |
-
}
|
540 |
-
}
|
541 |
-
layer {
|
542 |
-
name: "batch_norm13"
|
543 |
-
type: "BatchNorm"
|
544 |
-
bottom: "conv_blob13"
|
545 |
-
top: "batch_norm_blob13"
|
546 |
-
batch_norm_param {
|
547 |
-
use_global_stats: true
|
548 |
-
eps: 9.9999997e-06
|
549 |
-
}
|
550 |
-
}
|
551 |
-
layer {
|
552 |
-
name: "bn_scale13"
|
553 |
-
type: "Scale"
|
554 |
-
bottom: "batch_norm_blob13"
|
555 |
-
top: "batch_norm_blob13"
|
556 |
-
scale_param {
|
557 |
-
bias_term: true
|
558 |
-
}
|
559 |
-
}
|
560 |
-
layer {
|
561 |
-
name: "relu13"
|
562 |
-
type: "ReLU"
|
563 |
-
bottom: "batch_norm_blob13"
|
564 |
-
top: "relu_blob13"
|
565 |
-
}
|
566 |
-
layer {
|
567 |
-
name: "conv14"
|
568 |
-
type: "Convolution"
|
569 |
-
bottom: "relu_blob13"
|
570 |
-
top: "conv_blob14"
|
571 |
-
convolution_param {
|
572 |
-
num_output: 128
|
573 |
-
bias_term: false
|
574 |
-
pad: 1
|
575 |
-
kernel_size: 3
|
576 |
-
group: 128
|
577 |
-
stride: 1
|
578 |
-
weight_filler {
|
579 |
-
type: "xavier"
|
580 |
-
}
|
581 |
-
dilation: 1
|
582 |
-
}
|
583 |
-
}
|
584 |
-
layer {
|
585 |
-
name: "batch_norm14"
|
586 |
-
type: "BatchNorm"
|
587 |
-
bottom: "conv_blob14"
|
588 |
-
top: "batch_norm_blob14"
|
589 |
-
batch_norm_param {
|
590 |
-
use_global_stats: true
|
591 |
-
eps: 9.9999997e-06
|
592 |
-
}
|
593 |
-
}
|
594 |
-
layer {
|
595 |
-
name: "bn_scale14"
|
596 |
-
type: "Scale"
|
597 |
-
bottom: "batch_norm_blob14"
|
598 |
-
top: "batch_norm_blob14"
|
599 |
-
scale_param {
|
600 |
-
bias_term: true
|
601 |
-
}
|
602 |
-
}
|
603 |
-
layer {
|
604 |
-
name: "relu14"
|
605 |
-
type: "ReLU"
|
606 |
-
bottom: "batch_norm_blob14"
|
607 |
-
top: "relu_blob14"
|
608 |
-
}
|
609 |
-
layer {
|
610 |
-
name: "conv15"
|
611 |
-
type: "Convolution"
|
612 |
-
bottom: "relu_blob14"
|
613 |
-
top: "conv_blob15"
|
614 |
-
convolution_param {
|
615 |
-
num_output: 128
|
616 |
-
bias_term: false
|
617 |
-
pad: 0
|
618 |
-
kernel_size: 1
|
619 |
-
group: 1
|
620 |
-
stride: 1
|
621 |
-
weight_filler {
|
622 |
-
type: "xavier"
|
623 |
-
}
|
624 |
-
dilation: 1
|
625 |
-
}
|
626 |
-
}
|
627 |
-
layer {
|
628 |
-
name: "batch_norm15"
|
629 |
-
type: "BatchNorm"
|
630 |
-
bottom: "conv_blob15"
|
631 |
-
top: "batch_norm_blob15"
|
632 |
-
batch_norm_param {
|
633 |
-
use_global_stats: true
|
634 |
-
eps: 9.9999997e-06
|
635 |
-
}
|
636 |
-
}
|
637 |
-
layer {
|
638 |
-
name: "bn_scale15"
|
639 |
-
type: "Scale"
|
640 |
-
bottom: "batch_norm_blob15"
|
641 |
-
top: "batch_norm_blob15"
|
642 |
-
scale_param {
|
643 |
-
bias_term: true
|
644 |
-
}
|
645 |
-
}
|
646 |
-
layer {
|
647 |
-
name: "relu15"
|
648 |
-
type: "ReLU"
|
649 |
-
bottom: "batch_norm_blob15"
|
650 |
-
top: "relu_blob15"
|
651 |
-
}
|
652 |
-
layer {
|
653 |
-
name: "conv16"
|
654 |
-
type: "Convolution"
|
655 |
-
bottom: "relu_blob15"
|
656 |
-
top: "conv_blob16"
|
657 |
-
convolution_param {
|
658 |
-
num_output: 128
|
659 |
-
bias_term: false
|
660 |
-
pad: 1
|
661 |
-
kernel_size: 3
|
662 |
-
group: 128
|
663 |
-
stride: 1
|
664 |
-
weight_filler {
|
665 |
-
type: "xavier"
|
666 |
-
}
|
667 |
-
dilation: 1
|
668 |
-
}
|
669 |
-
}
|
670 |
-
layer {
|
671 |
-
name: "batch_norm16"
|
672 |
-
type: "BatchNorm"
|
673 |
-
bottom: "conv_blob16"
|
674 |
-
top: "batch_norm_blob16"
|
675 |
-
batch_norm_param {
|
676 |
-
use_global_stats: true
|
677 |
-
eps: 9.9999997e-06
|
678 |
-
}
|
679 |
-
}
|
680 |
-
layer {
|
681 |
-
name: "bn_scale16"
|
682 |
-
type: "Scale"
|
683 |
-
bottom: "batch_norm_blob16"
|
684 |
-
top: "batch_norm_blob16"
|
685 |
-
scale_param {
|
686 |
-
bias_term: true
|
687 |
-
}
|
688 |
-
}
|
689 |
-
layer {
|
690 |
-
name: "relu16"
|
691 |
-
type: "ReLU"
|
692 |
-
bottom: "batch_norm_blob16"
|
693 |
-
top: "relu_blob16"
|
694 |
-
}
|
695 |
-
layer {
|
696 |
-
name: "conv17"
|
697 |
-
type: "Convolution"
|
698 |
-
bottom: "relu_blob16"
|
699 |
-
top: "conv_blob17"
|
700 |
-
convolution_param {
|
701 |
-
num_output: 128
|
702 |
-
bias_term: false
|
703 |
-
pad: 0
|
704 |
-
kernel_size: 1
|
705 |
-
group: 1
|
706 |
-
stride: 1
|
707 |
-
weight_filler {
|
708 |
-
type: "xavier"
|
709 |
-
}
|
710 |
-
dilation: 1
|
711 |
-
}
|
712 |
-
}
|
713 |
-
layer {
|
714 |
-
name: "batch_norm17"
|
715 |
-
type: "BatchNorm"
|
716 |
-
bottom: "conv_blob17"
|
717 |
-
top: "batch_norm_blob17"
|
718 |
-
batch_norm_param {
|
719 |
-
use_global_stats: true
|
720 |
-
eps: 9.9999997e-06
|
721 |
-
}
|
722 |
-
}
|
723 |
-
layer {
|
724 |
-
name: "bn_scale17"
|
725 |
-
type: "Scale"
|
726 |
-
bottom: "batch_norm_blob17"
|
727 |
-
top: "batch_norm_blob17"
|
728 |
-
scale_param {
|
729 |
-
bias_term: true
|
730 |
-
}
|
731 |
-
}
|
732 |
-
layer {
|
733 |
-
name: "relu17"
|
734 |
-
type: "ReLU"
|
735 |
-
bottom: "batch_norm_blob17"
|
736 |
-
top: "relu_blob17"
|
737 |
-
}
|
738 |
-
layer {
|
739 |
-
name: "conv18"
|
740 |
-
type: "Convolution"
|
741 |
-
bottom: "relu_blob17"
|
742 |
-
top: "conv_blob18"
|
743 |
-
convolution_param {
|
744 |
-
num_output: 128
|
745 |
-
bias_term: false
|
746 |
-
pad: 1
|
747 |
-
kernel_size: 3
|
748 |
-
group: 128
|
749 |
-
stride: 1
|
750 |
-
weight_filler {
|
751 |
-
type: "xavier"
|
752 |
-
}
|
753 |
-
dilation: 1
|
754 |
-
}
|
755 |
-
}
|
756 |
-
layer {
|
757 |
-
name: "batch_norm18"
|
758 |
-
type: "BatchNorm"
|
759 |
-
bottom: "conv_blob18"
|
760 |
-
top: "batch_norm_blob18"
|
761 |
-
batch_norm_param {
|
762 |
-
use_global_stats: true
|
763 |
-
eps: 9.9999997e-06
|
764 |
-
}
|
765 |
-
}
|
766 |
-
layer {
|
767 |
-
name: "bn_scale18"
|
768 |
-
type: "Scale"
|
769 |
-
bottom: "batch_norm_blob18"
|
770 |
-
top: "batch_norm_blob18"
|
771 |
-
scale_param {
|
772 |
-
bias_term: true
|
773 |
-
}
|
774 |
-
}
|
775 |
-
layer {
|
776 |
-
name: "relu18"
|
777 |
-
type: "ReLU"
|
778 |
-
bottom: "batch_norm_blob18"
|
779 |
-
top: "relu_blob18"
|
780 |
-
}
|
781 |
-
layer {
|
782 |
-
name: "conv19"
|
783 |
-
type: "Convolution"
|
784 |
-
bottom: "relu_blob18"
|
785 |
-
top: "conv_blob19"
|
786 |
-
convolution_param {
|
787 |
-
num_output: 128
|
788 |
-
bias_term: false
|
789 |
-
pad: 0
|
790 |
-
kernel_size: 1
|
791 |
-
group: 1
|
792 |
-
stride: 1
|
793 |
-
weight_filler {
|
794 |
-
type: "xavier"
|
795 |
-
}
|
796 |
-
dilation: 1
|
797 |
-
}
|
798 |
-
}
|
799 |
-
layer {
|
800 |
-
name: "batch_norm19"
|
801 |
-
type: "BatchNorm"
|
802 |
-
bottom: "conv_blob19"
|
803 |
-
top: "batch_norm_blob19"
|
804 |
-
batch_norm_param {
|
805 |
-
use_global_stats: true
|
806 |
-
eps: 9.9999997e-06
|
807 |
-
}
|
808 |
-
}
|
809 |
-
layer {
|
810 |
-
name: "bn_scale19"
|
811 |
-
type: "Scale"
|
812 |
-
bottom: "batch_norm_blob19"
|
813 |
-
top: "batch_norm_blob19"
|
814 |
-
scale_param {
|
815 |
-
bias_term: true
|
816 |
-
}
|
817 |
-
}
|
818 |
-
layer {
|
819 |
-
name: "relu19"
|
820 |
-
type: "ReLU"
|
821 |
-
bottom: "batch_norm_blob19"
|
822 |
-
top: "relu_blob19"
|
823 |
-
}
|
824 |
-
layer {
|
825 |
-
name: "conv20"
|
826 |
-
type: "Convolution"
|
827 |
-
bottom: "relu_blob19"
|
828 |
-
top: "conv_blob20"
|
829 |
-
convolution_param {
|
830 |
-
num_output: 128
|
831 |
-
bias_term: false
|
832 |
-
pad: 1
|
833 |
-
kernel_size: 3
|
834 |
-
group: 128
|
835 |
-
stride: 1
|
836 |
-
weight_filler {
|
837 |
-
type: "xavier"
|
838 |
-
}
|
839 |
-
dilation: 1
|
840 |
-
}
|
841 |
-
}
|
842 |
-
layer {
|
843 |
-
name: "batch_norm20"
|
844 |
-
type: "BatchNorm"
|
845 |
-
bottom: "conv_blob20"
|
846 |
-
top: "batch_norm_blob20"
|
847 |
-
batch_norm_param {
|
848 |
-
use_global_stats: true
|
849 |
-
eps: 9.9999997e-06
|
850 |
-
}
|
851 |
-
}
|
852 |
-
layer {
|
853 |
-
name: "bn_scale20"
|
854 |
-
type: "Scale"
|
855 |
-
bottom: "batch_norm_blob20"
|
856 |
-
top: "batch_norm_blob20"
|
857 |
-
scale_param {
|
858 |
-
bias_term: true
|
859 |
-
}
|
860 |
-
}
|
861 |
-
layer {
|
862 |
-
name: "relu20"
|
863 |
-
type: "ReLU"
|
864 |
-
bottom: "batch_norm_blob20"
|
865 |
-
top: "relu_blob20"
|
866 |
-
}
|
867 |
-
layer {
|
868 |
-
name: "conv21"
|
869 |
-
type: "Convolution"
|
870 |
-
bottom: "relu_blob20"
|
871 |
-
top: "conv_blob21"
|
872 |
-
convolution_param {
|
873 |
-
num_output: 128
|
874 |
-
bias_term: false
|
875 |
-
pad: 0
|
876 |
-
kernel_size: 1
|
877 |
-
group: 1
|
878 |
-
stride: 1
|
879 |
-
weight_filler {
|
880 |
-
type: "xavier"
|
881 |
-
}
|
882 |
-
dilation: 1
|
883 |
-
}
|
884 |
-
}
|
885 |
-
layer {
|
886 |
-
name: "batch_norm21"
|
887 |
-
type: "BatchNorm"
|
888 |
-
bottom: "conv_blob21"
|
889 |
-
top: "batch_norm_blob21"
|
890 |
-
batch_norm_param {
|
891 |
-
use_global_stats: true
|
892 |
-
eps: 9.9999997e-06
|
893 |
-
}
|
894 |
-
}
|
895 |
-
layer {
|
896 |
-
name: "bn_scale21"
|
897 |
-
type: "Scale"
|
898 |
-
bottom: "batch_norm_blob21"
|
899 |
-
top: "batch_norm_blob21"
|
900 |
-
scale_param {
|
901 |
-
bias_term: true
|
902 |
-
}
|
903 |
-
}
|
904 |
-
layer {
|
905 |
-
name: "relu21"
|
906 |
-
type: "ReLU"
|
907 |
-
bottom: "batch_norm_blob21"
|
908 |
-
top: "relu_blob21"
|
909 |
-
}
|
910 |
-
layer {
|
911 |
-
name: "conv22"
|
912 |
-
type: "Convolution"
|
913 |
-
bottom: "relu_blob21"
|
914 |
-
top: "conv_blob22"
|
915 |
-
convolution_param {
|
916 |
-
num_output: 128
|
917 |
-
bias_term: false
|
918 |
-
pad: 1
|
919 |
-
kernel_size: 3
|
920 |
-
group: 128
|
921 |
-
stride: 1
|
922 |
-
weight_filler {
|
923 |
-
type: "xavier"
|
924 |
-
}
|
925 |
-
dilation: 1
|
926 |
-
}
|
927 |
-
}
|
928 |
-
layer {
|
929 |
-
name: "batch_norm22"
|
930 |
-
type: "BatchNorm"
|
931 |
-
bottom: "conv_blob22"
|
932 |
-
top: "batch_norm_blob22"
|
933 |
-
batch_norm_param {
|
934 |
-
use_global_stats: true
|
935 |
-
eps: 9.9999997e-06
|
936 |
-
}
|
937 |
-
}
|
938 |
-
layer {
|
939 |
-
name: "bn_scale22"
|
940 |
-
type: "Scale"
|
941 |
-
bottom: "batch_norm_blob22"
|
942 |
-
top: "batch_norm_blob22"
|
943 |
-
scale_param {
|
944 |
-
bias_term: true
|
945 |
-
}
|
946 |
-
}
|
947 |
-
layer {
|
948 |
-
name: "relu22"
|
949 |
-
type: "ReLU"
|
950 |
-
bottom: "batch_norm_blob22"
|
951 |
-
top: "relu_blob22"
|
952 |
-
}
|
953 |
-
layer {
|
954 |
-
name: "conv23"
|
955 |
-
type: "Convolution"
|
956 |
-
bottom: "relu_blob22"
|
957 |
-
top: "conv_blob23"
|
958 |
-
convolution_param {
|
959 |
-
num_output: 128
|
960 |
-
bias_term: false
|
961 |
-
pad: 0
|
962 |
-
kernel_size: 1
|
963 |
-
group: 1
|
964 |
-
stride: 1
|
965 |
-
weight_filler {
|
966 |
-
type: "xavier"
|
967 |
-
}
|
968 |
-
dilation: 1
|
969 |
-
}
|
970 |
-
}
|
971 |
-
layer {
|
972 |
-
name: "batch_norm23"
|
973 |
-
type: "BatchNorm"
|
974 |
-
bottom: "conv_blob23"
|
975 |
-
top: "batch_norm_blob23"
|
976 |
-
batch_norm_param {
|
977 |
-
use_global_stats: true
|
978 |
-
eps: 9.9999997e-06
|
979 |
-
}
|
980 |
-
}
|
981 |
-
layer {
|
982 |
-
name: "bn_scale23"
|
983 |
-
type: "Scale"
|
984 |
-
bottom: "batch_norm_blob23"
|
985 |
-
top: "batch_norm_blob23"
|
986 |
-
scale_param {
|
987 |
-
bias_term: true
|
988 |
-
}
|
989 |
-
}
|
990 |
-
layer {
|
991 |
-
name: "relu23"
|
992 |
-
type: "ReLU"
|
993 |
-
bottom: "batch_norm_blob23"
|
994 |
-
top: "relu_blob23"
|
995 |
-
}
|
996 |
-
layer {
|
997 |
-
name: "conv24"
|
998 |
-
type: "Convolution"
|
999 |
-
bottom: "relu_blob23"
|
1000 |
-
top: "conv_blob24"
|
1001 |
-
convolution_param {
|
1002 |
-
num_output: 128
|
1003 |
-
bias_term: false
|
1004 |
-
pad: 1
|
1005 |
-
kernel_size: 3
|
1006 |
-
group: 128
|
1007 |
-
stride: 2
|
1008 |
-
weight_filler {
|
1009 |
-
type: "xavier"
|
1010 |
-
}
|
1011 |
-
dilation: 1
|
1012 |
-
}
|
1013 |
-
}
|
1014 |
-
layer {
|
1015 |
-
name: "batch_norm24"
|
1016 |
-
type: "BatchNorm"
|
1017 |
-
bottom: "conv_blob24"
|
1018 |
-
top: "batch_norm_blob24"
|
1019 |
-
batch_norm_param {
|
1020 |
-
use_global_stats: true
|
1021 |
-
eps: 9.9999997e-06
|
1022 |
-
}
|
1023 |
-
}
|
1024 |
-
layer {
|
1025 |
-
name: "bn_scale24"
|
1026 |
-
type: "Scale"
|
1027 |
-
bottom: "batch_norm_blob24"
|
1028 |
-
top: "batch_norm_blob24"
|
1029 |
-
scale_param {
|
1030 |
-
bias_term: true
|
1031 |
-
}
|
1032 |
-
}
|
1033 |
-
layer {
|
1034 |
-
name: "relu24"
|
1035 |
-
type: "ReLU"
|
1036 |
-
bottom: "batch_norm_blob24"
|
1037 |
-
top: "relu_blob24"
|
1038 |
-
}
|
1039 |
-
layer {
|
1040 |
-
name: "conv25"
|
1041 |
-
type: "Convolution"
|
1042 |
-
bottom: "relu_blob24"
|
1043 |
-
top: "conv_blob25"
|
1044 |
-
convolution_param {
|
1045 |
-
num_output: 256
|
1046 |
-
bias_term: false
|
1047 |
-
pad: 0
|
1048 |
-
kernel_size: 1
|
1049 |
-
group: 1
|
1050 |
-
stride: 1
|
1051 |
-
weight_filler {
|
1052 |
-
type: "xavier"
|
1053 |
-
}
|
1054 |
-
dilation: 1
|
1055 |
-
}
|
1056 |
-
}
|
1057 |
-
layer {
|
1058 |
-
name: "batch_norm25"
|
1059 |
-
type: "BatchNorm"
|
1060 |
-
bottom: "conv_blob25"
|
1061 |
-
top: "batch_norm_blob25"
|
1062 |
-
batch_norm_param {
|
1063 |
-
use_global_stats: true
|
1064 |
-
eps: 9.9999997e-06
|
1065 |
-
}
|
1066 |
-
}
|
1067 |
-
layer {
|
1068 |
-
name: "bn_scale25"
|
1069 |
-
type: "Scale"
|
1070 |
-
bottom: "batch_norm_blob25"
|
1071 |
-
top: "batch_norm_blob25"
|
1072 |
-
scale_param {
|
1073 |
-
bias_term: true
|
1074 |
-
}
|
1075 |
-
}
|
1076 |
-
layer {
|
1077 |
-
name: "relu25"
|
1078 |
-
type: "ReLU"
|
1079 |
-
bottom: "batch_norm_blob25"
|
1080 |
-
top: "relu_blob25"
|
1081 |
-
}
|
1082 |
-
layer {
|
1083 |
-
name: "conv26"
|
1084 |
-
type: "Convolution"
|
1085 |
-
bottom: "relu_blob25"
|
1086 |
-
top: "conv_blob26"
|
1087 |
-
convolution_param {
|
1088 |
-
num_output: 256
|
1089 |
-
bias_term: false
|
1090 |
-
pad: 1
|
1091 |
-
kernel_size: 3
|
1092 |
-
group: 256
|
1093 |
-
stride: 1
|
1094 |
-
weight_filler {
|
1095 |
-
type: "xavier"
|
1096 |
-
}
|
1097 |
-
dilation: 1
|
1098 |
-
}
|
1099 |
-
}
|
1100 |
-
layer {
|
1101 |
-
name: "batch_norm26"
|
1102 |
-
type: "BatchNorm"
|
1103 |
-
bottom: "conv_blob26"
|
1104 |
-
top: "batch_norm_blob26"
|
1105 |
-
batch_norm_param {
|
1106 |
-
use_global_stats: true
|
1107 |
-
eps: 9.9999997e-06
|
1108 |
-
}
|
1109 |
-
}
|
1110 |
-
layer {
|
1111 |
-
name: "bn_scale26"
|
1112 |
-
type: "Scale"
|
1113 |
-
bottom: "batch_norm_blob26"
|
1114 |
-
top: "batch_norm_blob26"
|
1115 |
-
scale_param {
|
1116 |
-
bias_term: true
|
1117 |
-
}
|
1118 |
-
}
|
1119 |
-
layer {
|
1120 |
-
name: "relu26"
|
1121 |
-
type: "ReLU"
|
1122 |
-
bottom: "batch_norm_blob26"
|
1123 |
-
top: "relu_blob26"
|
1124 |
-
}
|
1125 |
-
layer {
|
1126 |
-
name: "conv27"
|
1127 |
-
type: "Convolution"
|
1128 |
-
bottom: "relu_blob26"
|
1129 |
-
top: "conv_blob27"
|
1130 |
-
convolution_param {
|
1131 |
-
num_output: 256
|
1132 |
-
bias_term: false
|
1133 |
-
pad: 0
|
1134 |
-
kernel_size: 1
|
1135 |
-
group: 1
|
1136 |
-
stride: 1
|
1137 |
-
weight_filler {
|
1138 |
-
type: "xavier"
|
1139 |
-
}
|
1140 |
-
dilation: 1
|
1141 |
-
}
|
1142 |
-
}
|
1143 |
-
layer {
|
1144 |
-
name: "batch_norm27"
|
1145 |
-
type: "BatchNorm"
|
1146 |
-
bottom: "conv_blob27"
|
1147 |
-
top: "batch_norm_blob27"
|
1148 |
-
batch_norm_param {
|
1149 |
-
use_global_stats: true
|
1150 |
-
eps: 9.9999997e-06
|
1151 |
-
}
|
1152 |
-
}
|
1153 |
-
layer {
|
1154 |
-
name: "bn_scale27"
|
1155 |
-
type: "Scale"
|
1156 |
-
bottom: "batch_norm_blob27"
|
1157 |
-
top: "batch_norm_blob27"
|
1158 |
-
scale_param {
|
1159 |
-
bias_term: true
|
1160 |
-
}
|
1161 |
-
}
|
1162 |
-
layer {
|
1163 |
-
name: "relu27"
|
1164 |
-
type: "ReLU"
|
1165 |
-
bottom: "batch_norm_blob27"
|
1166 |
-
top: "relu_blob27"
|
1167 |
-
}
|
1168 |
-
layer {
|
1169 |
-
name: "conv28"
|
1170 |
-
type: "Convolution"
|
1171 |
-
bottom: "relu_blob11"
|
1172 |
-
top: "conv_blob28"
|
1173 |
-
convolution_param {
|
1174 |
-
num_output: 64
|
1175 |
-
bias_term: false
|
1176 |
-
pad: 0
|
1177 |
-
kernel_size: 1
|
1178 |
-
group: 1
|
1179 |
-
stride: 1
|
1180 |
-
weight_filler {
|
1181 |
-
type: "xavier"
|
1182 |
-
}
|
1183 |
-
dilation: 1
|
1184 |
-
}
|
1185 |
-
}
|
1186 |
-
layer {
|
1187 |
-
name: "batch_norm28"
|
1188 |
-
type: "BatchNorm"
|
1189 |
-
bottom: "conv_blob28"
|
1190 |
-
top: "batch_norm_blob28"
|
1191 |
-
batch_norm_param {
|
1192 |
-
use_global_stats: true
|
1193 |
-
eps: 9.9999997e-06
|
1194 |
-
}
|
1195 |
-
}
|
1196 |
-
layer {
|
1197 |
-
name: "bn_scale28"
|
1198 |
-
type: "Scale"
|
1199 |
-
bottom: "batch_norm_blob28"
|
1200 |
-
top: "batch_norm_blob28"
|
1201 |
-
scale_param {
|
1202 |
-
bias_term: true
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
layer {
|
1206 |
-
name: "relu28"
|
1207 |
-
type: "ReLU"
|
1208 |
-
bottom: "batch_norm_blob28"
|
1209 |
-
top: "relu_blob28"
|
1210 |
-
}
|
1211 |
-
layer {
|
1212 |
-
name: "conv29"
|
1213 |
-
type: "Convolution"
|
1214 |
-
bottom: "relu_blob23"
|
1215 |
-
top: "conv_blob29"
|
1216 |
-
convolution_param {
|
1217 |
-
num_output: 64
|
1218 |
-
bias_term: false
|
1219 |
-
pad: 0
|
1220 |
-
kernel_size: 1
|
1221 |
-
group: 1
|
1222 |
-
stride: 1
|
1223 |
-
weight_filler {
|
1224 |
-
type: "xavier"
|
1225 |
-
}
|
1226 |
-
dilation: 1
|
1227 |
-
}
|
1228 |
-
}
|
1229 |
-
layer {
|
1230 |
-
name: "batch_norm29"
|
1231 |
-
type: "BatchNorm"
|
1232 |
-
bottom: "conv_blob29"
|
1233 |
-
top: "batch_norm_blob29"
|
1234 |
-
batch_norm_param {
|
1235 |
-
use_global_stats: true
|
1236 |
-
eps: 9.9999997e-06
|
1237 |
-
}
|
1238 |
-
}
|
1239 |
-
layer {
|
1240 |
-
name: "bn_scale29"
|
1241 |
-
type: "Scale"
|
1242 |
-
bottom: "batch_norm_blob29"
|
1243 |
-
top: "batch_norm_blob29"
|
1244 |
-
scale_param {
|
1245 |
-
bias_term: true
|
1246 |
-
}
|
1247 |
-
}
|
1248 |
-
layer {
|
1249 |
-
name: "relu29"
|
1250 |
-
type: "ReLU"
|
1251 |
-
bottom: "batch_norm_blob29"
|
1252 |
-
top: "relu_blob29"
|
1253 |
-
}
|
1254 |
-
layer {
|
1255 |
-
name: "conv30"
|
1256 |
-
type: "Convolution"
|
1257 |
-
bottom: "relu_blob27"
|
1258 |
-
top: "conv_blob30"
|
1259 |
-
convolution_param {
|
1260 |
-
num_output: 64
|
1261 |
-
bias_term: false
|
1262 |
-
pad: 0
|
1263 |
-
kernel_size: 1
|
1264 |
-
group: 1
|
1265 |
-
stride: 1
|
1266 |
-
weight_filler {
|
1267 |
-
type: "xavier"
|
1268 |
-
}
|
1269 |
-
dilation: 1
|
1270 |
-
}
|
1271 |
-
}
|
1272 |
-
layer {
|
1273 |
-
name: "batch_norm30"
|
1274 |
-
type: "BatchNorm"
|
1275 |
-
bottom: "conv_blob30"
|
1276 |
-
top: "batch_norm_blob30"
|
1277 |
-
batch_norm_param {
|
1278 |
-
use_global_stats: true
|
1279 |
-
eps: 9.9999997e-06
|
1280 |
-
}
|
1281 |
-
}
|
1282 |
-
layer {
|
1283 |
-
name: "bn_scale30"
|
1284 |
-
type: "Scale"
|
1285 |
-
bottom: "batch_norm_blob30"
|
1286 |
-
top: "batch_norm_blob30"
|
1287 |
-
scale_param {
|
1288 |
-
bias_term: true
|
1289 |
-
}
|
1290 |
-
}
|
1291 |
-
layer {
|
1292 |
-
name: "relu30"
|
1293 |
-
type: "ReLU"
|
1294 |
-
bottom: "batch_norm_blob30"
|
1295 |
-
top: "relu_blob30"
|
1296 |
-
}
|
1297 |
-
layer {
|
1298 |
-
name: "conv_transpose1"
|
1299 |
-
type: "Deconvolution"
|
1300 |
-
bottom: "relu_blob30"
|
1301 |
-
top: "conv_transpose_blob1"
|
1302 |
-
convolution_param {
|
1303 |
-
num_output: 64
|
1304 |
-
bias_term: true
|
1305 |
-
pad: 0
|
1306 |
-
kernel_size: 2
|
1307 |
-
group: 1
|
1308 |
-
stride: 2
|
1309 |
-
weight_filler {
|
1310 |
-
type: "xavier"
|
1311 |
-
}
|
1312 |
-
bias_filler {
|
1313 |
-
type: "constant"
|
1314 |
-
}
|
1315 |
-
dilation: 1
|
1316 |
-
}
|
1317 |
-
}
|
1318 |
-
layer {
|
1319 |
-
name: "crop1"
|
1320 |
-
type: "Crop"
|
1321 |
-
bottom: "conv_transpose_blob1"
|
1322 |
-
bottom: "relu_blob29"
|
1323 |
-
top: "crop1"
|
1324 |
-
}
|
1325 |
-
layer {
|
1326 |
-
name: "add1"
|
1327 |
-
type: "Eltwise"
|
1328 |
-
bottom: "relu_blob29"
|
1329 |
-
bottom: "crop1"
|
1330 |
-
top: "add_blob1"
|
1331 |
-
eltwise_param {
|
1332 |
-
operation: SUM
|
1333 |
-
}
|
1334 |
-
}
|
1335 |
-
layer {
|
1336 |
-
name: "conv31"
|
1337 |
-
type: "Convolution"
|
1338 |
-
bottom: "add_blob1"
|
1339 |
-
top: "conv_blob31"
|
1340 |
-
convolution_param {
|
1341 |
-
num_output: 64
|
1342 |
-
bias_term: false
|
1343 |
-
pad: 1
|
1344 |
-
kernel_size: 3
|
1345 |
-
group: 1
|
1346 |
-
stride: 1
|
1347 |
-
weight_filler {
|
1348 |
-
type: "xavier"
|
1349 |
-
}
|
1350 |
-
dilation: 1
|
1351 |
-
}
|
1352 |
-
}
|
1353 |
-
layer {
|
1354 |
-
name: "batch_norm31"
|
1355 |
-
type: "BatchNorm"
|
1356 |
-
bottom: "conv_blob31"
|
1357 |
-
top: "batch_norm_blob31"
|
1358 |
-
batch_norm_param {
|
1359 |
-
use_global_stats: true
|
1360 |
-
eps: 9.9999997e-06
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
layer {
|
1364 |
-
name: "bn_scale31"
|
1365 |
-
type: "Scale"
|
1366 |
-
bottom: "batch_norm_blob31"
|
1367 |
-
top: "batch_norm_blob31"
|
1368 |
-
scale_param {
|
1369 |
-
bias_term: true
|
1370 |
-
}
|
1371 |
-
}
|
1372 |
-
layer {
|
1373 |
-
name: "relu31"
|
1374 |
-
type: "ReLU"
|
1375 |
-
bottom: "batch_norm_blob31"
|
1376 |
-
top: "relu_blob31"
|
1377 |
-
}
|
1378 |
-
layer {
|
1379 |
-
name: "conv_transpose2"
|
1380 |
-
type: "Deconvolution"
|
1381 |
-
bottom: "relu_blob31"
|
1382 |
-
top: "conv_transpose_blob2"
|
1383 |
-
convolution_param {
|
1384 |
-
num_output: 64
|
1385 |
-
bias_term: true
|
1386 |
-
pad: 0
|
1387 |
-
kernel_size: 2
|
1388 |
-
group: 1
|
1389 |
-
stride: 2
|
1390 |
-
weight_filler {
|
1391 |
-
type: "xavier"
|
1392 |
-
}
|
1393 |
-
bias_filler {
|
1394 |
-
type: "constant"
|
1395 |
-
}
|
1396 |
-
dilation: 1
|
1397 |
-
}
|
1398 |
-
}
|
1399 |
-
layer {
|
1400 |
-
name: "crop2"
|
1401 |
-
type: "Crop"
|
1402 |
-
bottom: "conv_transpose_blob2"
|
1403 |
-
bottom: "relu_blob28"
|
1404 |
-
top: "crop2"
|
1405 |
-
}
|
1406 |
-
layer {
|
1407 |
-
name: "add2"
|
1408 |
-
type: "Eltwise"
|
1409 |
-
bottom: "relu_blob28"
|
1410 |
-
bottom: "crop2"
|
1411 |
-
top: "add_blob2"
|
1412 |
-
eltwise_param {
|
1413 |
-
operation: SUM
|
1414 |
-
}
|
1415 |
-
}
|
1416 |
-
layer {
|
1417 |
-
name: "conv32"
|
1418 |
-
type: "Convolution"
|
1419 |
-
bottom: "add_blob2"
|
1420 |
-
top: "conv_blob32"
|
1421 |
-
convolution_param {
|
1422 |
-
num_output: 64
|
1423 |
-
bias_term: false
|
1424 |
-
pad: 1
|
1425 |
-
kernel_size: 3
|
1426 |
-
group: 1
|
1427 |
-
stride: 1
|
1428 |
-
weight_filler {
|
1429 |
-
type: "xavier"
|
1430 |
-
}
|
1431 |
-
dilation: 1
|
1432 |
-
}
|
1433 |
-
}
|
1434 |
-
layer {
|
1435 |
-
name: "batch_norm32"
|
1436 |
-
type: "BatchNorm"
|
1437 |
-
bottom: "conv_blob32"
|
1438 |
-
top: "batch_norm_blob32"
|
1439 |
-
batch_norm_param {
|
1440 |
-
use_global_stats: true
|
1441 |
-
eps: 9.9999997e-06
|
1442 |
-
}
|
1443 |
-
}
|
1444 |
-
layer {
|
1445 |
-
name: "bn_scale32"
|
1446 |
-
type: "Scale"
|
1447 |
-
bottom: "batch_norm_blob32"
|
1448 |
-
top: "batch_norm_blob32"
|
1449 |
-
scale_param {
|
1450 |
-
bias_term: true
|
1451 |
-
}
|
1452 |
-
}
|
1453 |
-
layer {
|
1454 |
-
name: "relu32"
|
1455 |
-
type: "ReLU"
|
1456 |
-
bottom: "batch_norm_blob32"
|
1457 |
-
top: "relu_blob32"
|
1458 |
-
}
|
1459 |
-
layer {
|
1460 |
-
name: "conv33"
|
1461 |
-
type: "Convolution"
|
1462 |
-
bottom: "relu_blob32"
|
1463 |
-
top: "conv_blob33"
|
1464 |
-
convolution_param {
|
1465 |
-
num_output: 32
|
1466 |
-
bias_term: false
|
1467 |
-
pad: 1
|
1468 |
-
kernel_size: 3
|
1469 |
-
group: 1
|
1470 |
-
stride: 1
|
1471 |
-
weight_filler {
|
1472 |
-
type: "xavier"
|
1473 |
-
}
|
1474 |
-
dilation: 1
|
1475 |
-
}
|
1476 |
-
}
|
1477 |
-
layer {
|
1478 |
-
name: "batch_norm33"
|
1479 |
-
type: "BatchNorm"
|
1480 |
-
bottom: "conv_blob33"
|
1481 |
-
top: "batch_norm_blob33"
|
1482 |
-
batch_norm_param {
|
1483 |
-
use_global_stats: true
|
1484 |
-
eps: 9.9999997e-06
|
1485 |
-
}
|
1486 |
-
}
|
1487 |
-
layer {
|
1488 |
-
name: "bn_scale33"
|
1489 |
-
type: "Scale"
|
1490 |
-
bottom: "batch_norm_blob33"
|
1491 |
-
top: "batch_norm_blob33"
|
1492 |
-
scale_param {
|
1493 |
-
bias_term: true
|
1494 |
-
}
|
1495 |
-
}
|
1496 |
-
layer {
|
1497 |
-
name: "conv34"
|
1498 |
-
type: "Convolution"
|
1499 |
-
bottom: "relu_blob32"
|
1500 |
-
top: "conv_blob34"
|
1501 |
-
convolution_param {
|
1502 |
-
num_output: 16
|
1503 |
-
bias_term: false
|
1504 |
-
pad: 1
|
1505 |
-
kernel_size: 3
|
1506 |
-
group: 1
|
1507 |
-
stride: 1
|
1508 |
-
weight_filler {
|
1509 |
-
type: "xavier"
|
1510 |
-
}
|
1511 |
-
dilation: 1
|
1512 |
-
}
|
1513 |
-
}
|
1514 |
-
layer {
|
1515 |
-
name: "batch_norm34"
|
1516 |
-
type: "BatchNorm"
|
1517 |
-
bottom: "conv_blob34"
|
1518 |
-
top: "batch_norm_blob34"
|
1519 |
-
batch_norm_param {
|
1520 |
-
use_global_stats: true
|
1521 |
-
eps: 9.9999997e-06
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
layer {
|
1525 |
-
name: "bn_scale34"
|
1526 |
-
type: "Scale"
|
1527 |
-
bottom: "batch_norm_blob34"
|
1528 |
-
top: "batch_norm_blob34"
|
1529 |
-
scale_param {
|
1530 |
-
bias_term: true
|
1531 |
-
}
|
1532 |
-
}
|
1533 |
-
layer {
|
1534 |
-
name: "relu33"
|
1535 |
-
type: "ReLU"
|
1536 |
-
bottom: "batch_norm_blob34"
|
1537 |
-
top: "relu_blob33"
|
1538 |
-
}
|
1539 |
-
layer {
|
1540 |
-
name: "conv35"
|
1541 |
-
type: "Convolution"
|
1542 |
-
bottom: "relu_blob33"
|
1543 |
-
top: "conv_blob35"
|
1544 |
-
convolution_param {
|
1545 |
-
num_output: 16
|
1546 |
-
bias_term: false
|
1547 |
-
pad: 1
|
1548 |
-
kernel_size: 3
|
1549 |
-
group: 1
|
1550 |
-
stride: 1
|
1551 |
-
weight_filler {
|
1552 |
-
type: "xavier"
|
1553 |
-
}
|
1554 |
-
dilation: 1
|
1555 |
-
}
|
1556 |
-
}
|
1557 |
-
layer {
|
1558 |
-
name: "batch_norm35"
|
1559 |
-
type: "BatchNorm"
|
1560 |
-
bottom: "conv_blob35"
|
1561 |
-
top: "batch_norm_blob35"
|
1562 |
-
batch_norm_param {
|
1563 |
-
use_global_stats: true
|
1564 |
-
eps: 9.9999997e-06
|
1565 |
-
}
|
1566 |
-
}
|
1567 |
-
layer {
|
1568 |
-
name: "bn_scale35"
|
1569 |
-
type: "Scale"
|
1570 |
-
bottom: "batch_norm_blob35"
|
1571 |
-
top: "batch_norm_blob35"
|
1572 |
-
scale_param {
|
1573 |
-
bias_term: true
|
1574 |
-
}
|
1575 |
-
}
|
1576 |
-
layer {
|
1577 |
-
name: "conv36"
|
1578 |
-
type: "Convolution"
|
1579 |
-
bottom: "relu_blob33"
|
1580 |
-
top: "conv_blob36"
|
1581 |
-
convolution_param {
|
1582 |
-
num_output: 16
|
1583 |
-
bias_term: false
|
1584 |
-
pad: 1
|
1585 |
-
kernel_size: 3
|
1586 |
-
group: 1
|
1587 |
-
stride: 1
|
1588 |
-
weight_filler {
|
1589 |
-
type: "xavier"
|
1590 |
-
}
|
1591 |
-
dilation: 1
|
1592 |
-
}
|
1593 |
-
}
|
1594 |
-
layer {
|
1595 |
-
name: "batch_norm36"
|
1596 |
-
type: "BatchNorm"
|
1597 |
-
bottom: "conv_blob36"
|
1598 |
-
top: "batch_norm_blob36"
|
1599 |
-
batch_norm_param {
|
1600 |
-
use_global_stats: true
|
1601 |
-
eps: 9.9999997e-06
|
1602 |
-
}
|
1603 |
-
}
|
1604 |
-
layer {
|
1605 |
-
name: "bn_scale36"
|
1606 |
-
type: "Scale"
|
1607 |
-
bottom: "batch_norm_blob36"
|
1608 |
-
top: "batch_norm_blob36"
|
1609 |
-
scale_param {
|
1610 |
-
bias_term: true
|
1611 |
-
}
|
1612 |
-
}
|
1613 |
-
layer {
|
1614 |
-
name: "relu34"
|
1615 |
-
type: "ReLU"
|
1616 |
-
bottom: "batch_norm_blob36"
|
1617 |
-
top: "relu_blob34"
|
1618 |
-
}
|
1619 |
-
layer {
|
1620 |
-
name: "conv37"
|
1621 |
-
type: "Convolution"
|
1622 |
-
bottom: "relu_blob34"
|
1623 |
-
top: "conv_blob37"
|
1624 |
-
convolution_param {
|
1625 |
-
num_output: 16
|
1626 |
-
bias_term: false
|
1627 |
-
pad: 1
|
1628 |
-
kernel_size: 3
|
1629 |
-
group: 1
|
1630 |
-
stride: 1
|
1631 |
-
weight_filler {
|
1632 |
-
type: "xavier"
|
1633 |
-
}
|
1634 |
-
dilation: 1
|
1635 |
-
}
|
1636 |
-
}
|
1637 |
-
layer {
|
1638 |
-
name: "batch_norm37"
|
1639 |
-
type: "BatchNorm"
|
1640 |
-
bottom: "conv_blob37"
|
1641 |
-
top: "batch_norm_blob37"
|
1642 |
-
batch_norm_param {
|
1643 |
-
use_global_stats: true
|
1644 |
-
eps: 9.9999997e-06
|
1645 |
-
}
|
1646 |
-
}
|
1647 |
-
layer {
|
1648 |
-
name: "bn_scale37"
|
1649 |
-
type: "Scale"
|
1650 |
-
bottom: "batch_norm_blob37"
|
1651 |
-
top: "batch_norm_blob37"
|
1652 |
-
scale_param {
|
1653 |
-
bias_term: true
|
1654 |
-
}
|
1655 |
-
}
|
1656 |
-
layer {
|
1657 |
-
name: "cat1"
|
1658 |
-
type: "Concat"
|
1659 |
-
bottom: "batch_norm_blob33"
|
1660 |
-
bottom: "batch_norm_blob35"
|
1661 |
-
bottom: "batch_norm_blob37"
|
1662 |
-
top: "cat_blob1"
|
1663 |
-
concat_param {
|
1664 |
-
axis: 1
|
1665 |
-
}
|
1666 |
-
}
|
1667 |
-
layer {
|
1668 |
-
name: "relu35"
|
1669 |
-
type: "ReLU"
|
1670 |
-
bottom: "cat_blob1"
|
1671 |
-
top: "relu_blob35"
|
1672 |
-
}
|
1673 |
-
layer {
|
1674 |
-
name: "conv38"
|
1675 |
-
type: "Convolution"
|
1676 |
-
bottom: "relu_blob31"
|
1677 |
-
top: "conv_blob38"
|
1678 |
-
convolution_param {
|
1679 |
-
num_output: 32
|
1680 |
-
bias_term: false
|
1681 |
-
pad: 1
|
1682 |
-
kernel_size: 3
|
1683 |
-
group: 1
|
1684 |
-
stride: 1
|
1685 |
-
weight_filler {
|
1686 |
-
type: "xavier"
|
1687 |
-
}
|
1688 |
-
dilation: 1
|
1689 |
-
}
|
1690 |
-
}
|
1691 |
-
layer {
|
1692 |
-
name: "batch_norm38"
|
1693 |
-
type: "BatchNorm"
|
1694 |
-
bottom: "conv_blob38"
|
1695 |
-
top: "batch_norm_blob38"
|
1696 |
-
batch_norm_param {
|
1697 |
-
use_global_stats: true
|
1698 |
-
eps: 9.9999997e-06
|
1699 |
-
}
|
1700 |
-
}
|
1701 |
-
layer {
|
1702 |
-
name: "bn_scale38"
|
1703 |
-
type: "Scale"
|
1704 |
-
bottom: "batch_norm_blob38"
|
1705 |
-
top: "batch_norm_blob38"
|
1706 |
-
scale_param {
|
1707 |
-
bias_term: true
|
1708 |
-
}
|
1709 |
-
}
|
1710 |
-
layer {
|
1711 |
-
name: "conv39"
|
1712 |
-
type: "Convolution"
|
1713 |
-
bottom: "relu_blob31"
|
1714 |
-
top: "conv_blob39"
|
1715 |
-
convolution_param {
|
1716 |
-
num_output: 16
|
1717 |
-
bias_term: false
|
1718 |
-
pad: 1
|
1719 |
-
kernel_size: 3
|
1720 |
-
group: 1
|
1721 |
-
stride: 1
|
1722 |
-
weight_filler {
|
1723 |
-
type: "xavier"
|
1724 |
-
}
|
1725 |
-
dilation: 1
|
1726 |
-
}
|
1727 |
-
}
|
1728 |
-
layer {
|
1729 |
-
name: "batch_norm39"
|
1730 |
-
type: "BatchNorm"
|
1731 |
-
bottom: "conv_blob39"
|
1732 |
-
top: "batch_norm_blob39"
|
1733 |
-
batch_norm_param {
|
1734 |
-
use_global_stats: true
|
1735 |
-
eps: 9.9999997e-06
|
1736 |
-
}
|
1737 |
-
}
|
1738 |
-
layer {
|
1739 |
-
name: "bn_scale39"
|
1740 |
-
type: "Scale"
|
1741 |
-
bottom: "batch_norm_blob39"
|
1742 |
-
top: "batch_norm_blob39"
|
1743 |
-
scale_param {
|
1744 |
-
bias_term: true
|
1745 |
-
}
|
1746 |
-
}
|
1747 |
-
layer {
|
1748 |
-
name: "relu36"
|
1749 |
-
type: "ReLU"
|
1750 |
-
bottom: "batch_norm_blob39"
|
1751 |
-
top: "relu_blob36"
|
1752 |
-
}
|
1753 |
-
layer {
|
1754 |
-
name: "conv40"
|
1755 |
-
type: "Convolution"
|
1756 |
-
bottom: "relu_blob36"
|
1757 |
-
top: "conv_blob40"
|
1758 |
-
convolution_param {
|
1759 |
-
num_output: 16
|
1760 |
-
bias_term: false
|
1761 |
-
pad: 1
|
1762 |
-
kernel_size: 3
|
1763 |
-
group: 1
|
1764 |
-
stride: 1
|
1765 |
-
weight_filler {
|
1766 |
-
type: "xavier"
|
1767 |
-
}
|
1768 |
-
dilation: 1
|
1769 |
-
}
|
1770 |
-
}
|
1771 |
-
layer {
|
1772 |
-
name: "batch_norm40"
|
1773 |
-
type: "BatchNorm"
|
1774 |
-
bottom: "conv_blob40"
|
1775 |
-
top: "batch_norm_blob40"
|
1776 |
-
batch_norm_param {
|
1777 |
-
use_global_stats: true
|
1778 |
-
eps: 9.9999997e-06
|
1779 |
-
}
|
1780 |
-
}
|
1781 |
-
layer {
|
1782 |
-
name: "bn_scale40"
|
1783 |
-
type: "Scale"
|
1784 |
-
bottom: "batch_norm_blob40"
|
1785 |
-
top: "batch_norm_blob40"
|
1786 |
-
scale_param {
|
1787 |
-
bias_term: true
|
1788 |
-
}
|
1789 |
-
}
|
1790 |
-
layer {
|
1791 |
-
name: "conv41"
|
1792 |
-
type: "Convolution"
|
1793 |
-
bottom: "relu_blob36"
|
1794 |
-
top: "conv_blob41"
|
1795 |
-
convolution_param {
|
1796 |
-
num_output: 16
|
1797 |
-
bias_term: false
|
1798 |
-
pad: 1
|
1799 |
-
kernel_size: 3
|
1800 |
-
group: 1
|
1801 |
-
stride: 1
|
1802 |
-
weight_filler {
|
1803 |
-
type: "xavier"
|
1804 |
-
}
|
1805 |
-
dilation: 1
|
1806 |
-
}
|
1807 |
-
}
|
1808 |
-
layer {
|
1809 |
-
name: "batch_norm41"
|
1810 |
-
type: "BatchNorm"
|
1811 |
-
bottom: "conv_blob41"
|
1812 |
-
top: "batch_norm_blob41"
|
1813 |
-
batch_norm_param {
|
1814 |
-
use_global_stats: true
|
1815 |
-
eps: 9.9999997e-06
|
1816 |
-
}
|
1817 |
-
}
|
1818 |
-
layer {
|
1819 |
-
name: "bn_scale41"
|
1820 |
-
type: "Scale"
|
1821 |
-
bottom: "batch_norm_blob41"
|
1822 |
-
top: "batch_norm_blob41"
|
1823 |
-
scale_param {
|
1824 |
-
bias_term: true
|
1825 |
-
}
|
1826 |
-
}
|
1827 |
-
layer {
|
1828 |
-
name: "relu37"
|
1829 |
-
type: "ReLU"
|
1830 |
-
bottom: "batch_norm_blob41"
|
1831 |
-
top: "relu_blob37"
|
1832 |
-
}
|
1833 |
-
layer {
|
1834 |
-
name: "conv42"
|
1835 |
-
type: "Convolution"
|
1836 |
-
bottom: "relu_blob37"
|
1837 |
-
top: "conv_blob42"
|
1838 |
-
convolution_param {
|
1839 |
-
num_output: 16
|
1840 |
-
bias_term: false
|
1841 |
-
pad: 1
|
1842 |
-
kernel_size: 3
|
1843 |
-
group: 1
|
1844 |
-
stride: 1
|
1845 |
-
weight_filler {
|
1846 |
-
type: "xavier"
|
1847 |
-
}
|
1848 |
-
dilation: 1
|
1849 |
-
}
|
1850 |
-
}
|
1851 |
-
layer {
|
1852 |
-
name: "batch_norm42"
|
1853 |
-
type: "BatchNorm"
|
1854 |
-
bottom: "conv_blob42"
|
1855 |
-
top: "batch_norm_blob42"
|
1856 |
-
batch_norm_param {
|
1857 |
-
use_global_stats: true
|
1858 |
-
eps: 9.9999997e-06
|
1859 |
-
}
|
1860 |
-
}
|
1861 |
-
layer {
|
1862 |
-
name: "bn_scale42"
|
1863 |
-
type: "Scale"
|
1864 |
-
bottom: "batch_norm_blob42"
|
1865 |
-
top: "batch_norm_blob42"
|
1866 |
-
scale_param {
|
1867 |
-
bias_term: true
|
1868 |
-
}
|
1869 |
-
}
|
1870 |
-
layer {
|
1871 |
-
name: "cat2"
|
1872 |
-
type: "Concat"
|
1873 |
-
bottom: "batch_norm_blob38"
|
1874 |
-
bottom: "batch_norm_blob40"
|
1875 |
-
bottom: "batch_norm_blob42"
|
1876 |
-
top: "cat_blob2"
|
1877 |
-
concat_param {
|
1878 |
-
axis: 1
|
1879 |
-
}
|
1880 |
-
}
|
1881 |
-
layer {
|
1882 |
-
name: "relu38"
|
1883 |
-
type: "ReLU"
|
1884 |
-
bottom: "cat_blob2"
|
1885 |
-
top: "relu_blob38"
|
1886 |
-
}
|
1887 |
-
layer {
|
1888 |
-
name: "conv43"
|
1889 |
-
type: "Convolution"
|
1890 |
-
bottom: "relu_blob30"
|
1891 |
-
top: "conv_blob43"
|
1892 |
-
convolution_param {
|
1893 |
-
num_output: 32
|
1894 |
-
bias_term: false
|
1895 |
-
pad: 1
|
1896 |
-
kernel_size: 3
|
1897 |
-
group: 1
|
1898 |
-
stride: 1
|
1899 |
-
weight_filler {
|
1900 |
-
type: "xavier"
|
1901 |
-
}
|
1902 |
-
dilation: 1
|
1903 |
-
}
|
1904 |
-
}
|
1905 |
-
layer {
|
1906 |
-
name: "batch_norm43"
|
1907 |
-
type: "BatchNorm"
|
1908 |
-
bottom: "conv_blob43"
|
1909 |
-
top: "batch_norm_blob43"
|
1910 |
-
batch_norm_param {
|
1911 |
-
use_global_stats: true
|
1912 |
-
eps: 9.9999997e-06
|
1913 |
-
}
|
1914 |
-
}
|
1915 |
-
layer {
|
1916 |
-
name: "bn_scale43"
|
1917 |
-
type: "Scale"
|
1918 |
-
bottom: "batch_norm_blob43"
|
1919 |
-
top: "batch_norm_blob43"
|
1920 |
-
scale_param {
|
1921 |
-
bias_term: true
|
1922 |
-
}
|
1923 |
-
}
|
1924 |
-
layer {
|
1925 |
-
name: "conv44"
|
1926 |
-
type: "Convolution"
|
1927 |
-
bottom: "relu_blob30"
|
1928 |
-
top: "conv_blob44"
|
1929 |
-
convolution_param {
|
1930 |
-
num_output: 16
|
1931 |
-
bias_term: false
|
1932 |
-
pad: 1
|
1933 |
-
kernel_size: 3
|
1934 |
-
group: 1
|
1935 |
-
stride: 1
|
1936 |
-
weight_filler {
|
1937 |
-
type: "xavier"
|
1938 |
-
}
|
1939 |
-
dilation: 1
|
1940 |
-
}
|
1941 |
-
}
|
1942 |
-
layer {
|
1943 |
-
name: "batch_norm44"
|
1944 |
-
type: "BatchNorm"
|
1945 |
-
bottom: "conv_blob44"
|
1946 |
-
top: "batch_norm_blob44"
|
1947 |
-
batch_norm_param {
|
1948 |
-
use_global_stats: true
|
1949 |
-
eps: 9.9999997e-06
|
1950 |
-
}
|
1951 |
-
}
|
1952 |
-
layer {
|
1953 |
-
name: "bn_scale44"
|
1954 |
-
type: "Scale"
|
1955 |
-
bottom: "batch_norm_blob44"
|
1956 |
-
top: "batch_norm_blob44"
|
1957 |
-
scale_param {
|
1958 |
-
bias_term: true
|
1959 |
-
}
|
1960 |
-
}
|
1961 |
-
layer {
|
1962 |
-
name: "relu39"
|
1963 |
-
type: "ReLU"
|
1964 |
-
bottom: "batch_norm_blob44"
|
1965 |
-
top: "relu_blob39"
|
1966 |
-
}
|
1967 |
-
layer {
|
1968 |
-
name: "conv45"
|
1969 |
-
type: "Convolution"
|
1970 |
-
bottom: "relu_blob39"
|
1971 |
-
top: "conv_blob45"
|
1972 |
-
convolution_param {
|
1973 |
-
num_output: 16
|
1974 |
-
bias_term: false
|
1975 |
-
pad: 1
|
1976 |
-
kernel_size: 3
|
1977 |
-
group: 1
|
1978 |
-
stride: 1
|
1979 |
-
weight_filler {
|
1980 |
-
type: "xavier"
|
1981 |
-
}
|
1982 |
-
dilation: 1
|
1983 |
-
}
|
1984 |
-
}
|
1985 |
-
layer {
|
1986 |
-
name: "batch_norm45"
|
1987 |
-
type: "BatchNorm"
|
1988 |
-
bottom: "conv_blob45"
|
1989 |
-
top: "batch_norm_blob45"
|
1990 |
-
batch_norm_param {
|
1991 |
-
use_global_stats: true
|
1992 |
-
eps: 9.9999997e-06
|
1993 |
-
}
|
1994 |
-
}
|
1995 |
-
layer {
|
1996 |
-
name: "bn_scale45"
|
1997 |
-
type: "Scale"
|
1998 |
-
bottom: "batch_norm_blob45"
|
1999 |
-
top: "batch_norm_blob45"
|
2000 |
-
scale_param {
|
2001 |
-
bias_term: true
|
2002 |
-
}
|
2003 |
-
}
|
2004 |
-
layer {
|
2005 |
-
name: "conv46"
|
2006 |
-
type: "Convolution"
|
2007 |
-
bottom: "relu_blob39"
|
2008 |
-
top: "conv_blob46"
|
2009 |
-
convolution_param {
|
2010 |
-
num_output: 16
|
2011 |
-
bias_term: false
|
2012 |
-
pad: 1
|
2013 |
-
kernel_size: 3
|
2014 |
-
group: 1
|
2015 |
-
stride: 1
|
2016 |
-
weight_filler {
|
2017 |
-
type: "xavier"
|
2018 |
-
}
|
2019 |
-
dilation: 1
|
2020 |
-
}
|
2021 |
-
}
|
2022 |
-
layer {
|
2023 |
-
name: "batch_norm46"
|
2024 |
-
type: "BatchNorm"
|
2025 |
-
bottom: "conv_blob46"
|
2026 |
-
top: "batch_norm_blob46"
|
2027 |
-
batch_norm_param {
|
2028 |
-
use_global_stats: true
|
2029 |
-
eps: 9.9999997e-06
|
2030 |
-
}
|
2031 |
-
}
|
2032 |
-
layer {
|
2033 |
-
name: "bn_scale46"
|
2034 |
-
type: "Scale"
|
2035 |
-
bottom: "batch_norm_blob46"
|
2036 |
-
top: "batch_norm_blob46"
|
2037 |
-
scale_param {
|
2038 |
-
bias_term: true
|
2039 |
-
}
|
2040 |
-
}
|
2041 |
-
layer {
|
2042 |
-
name: "relu40"
|
2043 |
-
type: "ReLU"
|
2044 |
-
bottom: "batch_norm_blob46"
|
2045 |
-
top: "relu_blob40"
|
2046 |
-
}
|
2047 |
-
layer {
|
2048 |
-
name: "conv47"
|
2049 |
-
type: "Convolution"
|
2050 |
-
bottom: "relu_blob40"
|
2051 |
-
top: "conv_blob47"
|
2052 |
-
convolution_param {
|
2053 |
-
num_output: 16
|
2054 |
-
bias_term: false
|
2055 |
-
pad: 1
|
2056 |
-
kernel_size: 3
|
2057 |
-
group: 1
|
2058 |
-
stride: 1
|
2059 |
-
weight_filler {
|
2060 |
-
type: "xavier"
|
2061 |
-
}
|
2062 |
-
dilation: 1
|
2063 |
-
}
|
2064 |
-
}
|
2065 |
-
layer {
|
2066 |
-
name: "batch_norm47"
|
2067 |
-
type: "BatchNorm"
|
2068 |
-
bottom: "conv_blob47"
|
2069 |
-
top: "batch_norm_blob47"
|
2070 |
-
batch_norm_param {
|
2071 |
-
use_global_stats: true
|
2072 |
-
eps: 9.9999997e-06
|
2073 |
-
}
|
2074 |
-
}
|
2075 |
-
layer {
|
2076 |
-
name: "bn_scale47"
|
2077 |
-
type: "Scale"
|
2078 |
-
bottom: "batch_norm_blob47"
|
2079 |
-
top: "batch_norm_blob47"
|
2080 |
-
scale_param {
|
2081 |
-
bias_term: true
|
2082 |
-
}
|
2083 |
-
}
|
2084 |
-
layer {
|
2085 |
-
name: "cat3"
|
2086 |
-
type: "Concat"
|
2087 |
-
bottom: "batch_norm_blob43"
|
2088 |
-
bottom: "batch_norm_blob45"
|
2089 |
-
bottom: "batch_norm_blob47"
|
2090 |
-
top: "cat_blob3"
|
2091 |
-
concat_param {
|
2092 |
-
axis: 1
|
2093 |
-
}
|
2094 |
-
}
|
2095 |
-
layer {
|
2096 |
-
name: "relu41"
|
2097 |
-
type: "ReLU"
|
2098 |
-
bottom: "cat_blob3"
|
2099 |
-
top: "relu_blob41"
|
2100 |
-
}
|
2101 |
-
layer {
|
2102 |
-
name: "conv48"
|
2103 |
-
type: "Convolution"
|
2104 |
-
bottom: "relu_blob35"
|
2105 |
-
top: "conv_blob48"
|
2106 |
-
convolution_param {
|
2107 |
-
num_output: 8
|
2108 |
-
bias_term: true
|
2109 |
-
pad: 0
|
2110 |
-
kernel_size: 1
|
2111 |
-
group: 1
|
2112 |
-
stride: 1
|
2113 |
-
weight_filler {
|
2114 |
-
type: "xavier"
|
2115 |
-
}
|
2116 |
-
bias_filler {
|
2117 |
-
type: "constant"
|
2118 |
-
}
|
2119 |
-
dilation: 1
|
2120 |
-
}
|
2121 |
-
}
|
2122 |
-
layer {
|
2123 |
-
name: "conv49"
|
2124 |
-
type: "Convolution"
|
2125 |
-
bottom: "relu_blob35"
|
2126 |
-
top: "conv_blob49"
|
2127 |
-
convolution_param {
|
2128 |
-
num_output: 4
|
2129 |
-
bias_term: true
|
2130 |
-
pad: 0
|
2131 |
-
kernel_size: 1
|
2132 |
-
group: 1
|
2133 |
-
stride: 1
|
2134 |
-
weight_filler {
|
2135 |
-
type: "xavier"
|
2136 |
-
}
|
2137 |
-
bias_filler {
|
2138 |
-
type: "constant"
|
2139 |
-
}
|
2140 |
-
dilation: 1
|
2141 |
-
}
|
2142 |
-
}
|
2143 |
-
layer {
|
2144 |
-
name: "conv50"
|
2145 |
-
type: "Convolution"
|
2146 |
-
bottom: "relu_blob38"
|
2147 |
-
top: "conv_blob50"
|
2148 |
-
convolution_param {
|
2149 |
-
num_output: 8
|
2150 |
-
bias_term: true
|
2151 |
-
pad: 0
|
2152 |
-
kernel_size: 1
|
2153 |
-
group: 1
|
2154 |
-
stride: 1
|
2155 |
-
weight_filler {
|
2156 |
-
type: "xavier"
|
2157 |
-
}
|
2158 |
-
bias_filler {
|
2159 |
-
type: "constant"
|
2160 |
-
}
|
2161 |
-
dilation: 1
|
2162 |
-
}
|
2163 |
-
}
|
2164 |
-
layer {
|
2165 |
-
name: "conv51"
|
2166 |
-
type: "Convolution"
|
2167 |
-
bottom: "relu_blob38"
|
2168 |
-
top: "conv_blob51"
|
2169 |
-
convolution_param {
|
2170 |
-
num_output: 4
|
2171 |
-
bias_term: true
|
2172 |
-
pad: 0
|
2173 |
-
kernel_size: 1
|
2174 |
-
group: 1
|
2175 |
-
stride: 1
|
2176 |
-
weight_filler {
|
2177 |
-
type: "xavier"
|
2178 |
-
}
|
2179 |
-
bias_filler {
|
2180 |
-
type: "constant"
|
2181 |
-
}
|
2182 |
-
dilation: 1
|
2183 |
-
}
|
2184 |
-
}
|
2185 |
-
layer {
|
2186 |
-
name: "conv52"
|
2187 |
-
type: "Convolution"
|
2188 |
-
bottom: "relu_blob41"
|
2189 |
-
top: "conv_blob52"
|
2190 |
-
convolution_param {
|
2191 |
-
num_output: 8
|
2192 |
-
bias_term: true
|
2193 |
-
pad: 0
|
2194 |
-
kernel_size: 1
|
2195 |
-
group: 1
|
2196 |
-
stride: 1
|
2197 |
-
weight_filler {
|
2198 |
-
type: "xavier"
|
2199 |
-
}
|
2200 |
-
bias_filler {
|
2201 |
-
type: "constant"
|
2202 |
-
}
|
2203 |
-
dilation: 1
|
2204 |
-
}
|
2205 |
-
}
|
2206 |
-
layer {
|
2207 |
-
name: "conv53"
|
2208 |
-
type: "Convolution"
|
2209 |
-
bottom: "relu_blob41"
|
2210 |
-
top: "conv_blob53"
|
2211 |
-
convolution_param {
|
2212 |
-
num_output: 4
|
2213 |
-
bias_term: true
|
2214 |
-
pad: 0
|
2215 |
-
kernel_size: 1
|
2216 |
-
group: 1
|
2217 |
-
stride: 1
|
2218 |
-
weight_filler {
|
2219 |
-
type: "xavier"
|
2220 |
-
}
|
2221 |
-
bias_filler {
|
2222 |
-
type: "constant"
|
2223 |
-
}
|
2224 |
-
dilation: 1
|
2225 |
-
}
|
2226 |
-
}
|
2227 |
-
############ prior box ###########
|
2228 |
-
|
2229 |
-
layer {
|
2230 |
-
name: "conv4_3_norm_mbox_loc_perm"
|
2231 |
-
type: "Permute"
|
2232 |
-
bottom: "conv_blob48"
|
2233 |
-
top: "conv4_3_norm_mbox_loc_perm"
|
2234 |
-
permute_param {
|
2235 |
-
order: 0
|
2236 |
-
order: 2
|
2237 |
-
order: 3
|
2238 |
-
order: 1
|
2239 |
-
}
|
2240 |
-
}
|
2241 |
-
layer {
|
2242 |
-
name: "conv4_3_norm_mbox_loc_flat"
|
2243 |
-
type: "Flatten"
|
2244 |
-
bottom: "conv4_3_norm_mbox_loc_perm"
|
2245 |
-
top: "conv4_3_norm_mbox_loc_flat"
|
2246 |
-
flatten_param {
|
2247 |
-
axis: 1
|
2248 |
-
}
|
2249 |
-
}
|
2250 |
-
layer {
|
2251 |
-
name: "conv4_3_norm_mbox_conf_perm"
|
2252 |
-
type: "Permute"
|
2253 |
-
bottom: "conv_blob49"
|
2254 |
-
top: "conv4_3_norm_mbox_conf_perm"
|
2255 |
-
permute_param {
|
2256 |
-
order: 0
|
2257 |
-
order: 2
|
2258 |
-
order: 3
|
2259 |
-
order: 1
|
2260 |
-
}
|
2261 |
-
}
|
2262 |
-
layer {
|
2263 |
-
name: "conv4_3_norm_mbox_conf_flat"
|
2264 |
-
type: "Flatten"
|
2265 |
-
bottom: "conv4_3_norm_mbox_conf_perm"
|
2266 |
-
top: "conv4_3_norm_mbox_conf_flat"
|
2267 |
-
flatten_param {
|
2268 |
-
axis: 1
|
2269 |
-
}
|
2270 |
-
}
|
2271 |
-
layer {
|
2272 |
-
name: "conv4_3_norm_mbox_priorbox"
|
2273 |
-
type: "PriorBox"
|
2274 |
-
bottom: "relu_blob35"
|
2275 |
-
bottom: "data"
|
2276 |
-
top: "conv4_3_norm_mbox_priorbox"
|
2277 |
-
prior_box_param {
|
2278 |
-
min_size: 16.0
|
2279 |
-
min_size: 32.0
|
2280 |
-
clip: false
|
2281 |
-
variance: 0.1
|
2282 |
-
variance: 0.1
|
2283 |
-
variance: 0.2
|
2284 |
-
variance: 0.2
|
2285 |
-
step: 8.0
|
2286 |
-
offset: 0.5
|
2287 |
-
}
|
2288 |
-
}
|
2289 |
-
|
2290 |
-
layer {
|
2291 |
-
name: "conv5_3_norm_mbox_loc_perm"
|
2292 |
-
type: "Permute"
|
2293 |
-
bottom: "conv_blob50"
|
2294 |
-
top: "conv5_3_norm_mbox_loc_perm"
|
2295 |
-
permute_param {
|
2296 |
-
order: 0
|
2297 |
-
order: 2
|
2298 |
-
order: 3
|
2299 |
-
order: 1
|
2300 |
-
}
|
2301 |
-
}
|
2302 |
-
layer {
|
2303 |
-
name: "conv5_3_norm_mbox_loc_flat"
|
2304 |
-
type: "Flatten"
|
2305 |
-
bottom: "conv5_3_norm_mbox_loc_perm"
|
2306 |
-
top: "conv5_3_norm_mbox_loc_flat"
|
2307 |
-
flatten_param {
|
2308 |
-
axis: 1
|
2309 |
-
}
|
2310 |
-
}
|
2311 |
-
layer {
|
2312 |
-
name: "conv5_3_norm_mbox_conf_perm"
|
2313 |
-
type: "Permute"
|
2314 |
-
bottom: "conv_blob51"
|
2315 |
-
top: "conv5_3_norm_mbox_conf_perm"
|
2316 |
-
permute_param {
|
2317 |
-
order: 0
|
2318 |
-
order: 2
|
2319 |
-
order: 3
|
2320 |
-
order: 1
|
2321 |
-
}
|
2322 |
-
}
|
2323 |
-
layer {
|
2324 |
-
name: "conv5_3_norm_mbox_conf_flat"
|
2325 |
-
type: "Flatten"
|
2326 |
-
bottom: "conv5_3_norm_mbox_conf_perm"
|
2327 |
-
top: "conv5_3_norm_mbox_conf_flat"
|
2328 |
-
flatten_param {
|
2329 |
-
axis: 1
|
2330 |
-
}
|
2331 |
-
}
|
2332 |
-
layer {
|
2333 |
-
name: "conv5_3_norm_mbox_priorbox"
|
2334 |
-
type: "PriorBox"
|
2335 |
-
bottom: "relu_blob38"
|
2336 |
-
bottom: "data"
|
2337 |
-
top: "conv5_3_norm_mbox_priorbox"
|
2338 |
-
prior_box_param {
|
2339 |
-
min_size: 64.0
|
2340 |
-
min_size: 128.0
|
2341 |
-
clip: false
|
2342 |
-
variance: 0.1
|
2343 |
-
variance: 0.1
|
2344 |
-
variance: 0.2
|
2345 |
-
variance: 0.2
|
2346 |
-
step: 16.0
|
2347 |
-
offset: 0.5
|
2348 |
-
}
|
2349 |
-
}
|
2350 |
-
|
2351 |
-
layer {
|
2352 |
-
name: "conv6_3_norm_mbox_loc_perm"
|
2353 |
-
type: "Permute"
|
2354 |
-
bottom: "conv_blob52"
|
2355 |
-
top: "conv6_3_norm_mbox_loc_perm"
|
2356 |
-
permute_param {
|
2357 |
-
order: 0
|
2358 |
-
order: 2
|
2359 |
-
order: 3
|
2360 |
-
order: 1
|
2361 |
-
}
|
2362 |
-
}
|
2363 |
-
layer {
|
2364 |
-
name: "conv6_3_norm_mbox_loc_flat"
|
2365 |
-
type: "Flatten"
|
2366 |
-
bottom: "conv6_3_norm_mbox_loc_perm"
|
2367 |
-
top: "conv6_3_norm_mbox_loc_flat"
|
2368 |
-
flatten_param {
|
2369 |
-
axis: 1
|
2370 |
-
}
|
2371 |
-
}
|
2372 |
-
layer {
|
2373 |
-
name: "conv6_3_norm_mbox_conf_perm"
|
2374 |
-
type: "Permute"
|
2375 |
-
bottom: "conv_blob53"
|
2376 |
-
top: "conv6_3_norm_mbox_conf_perm"
|
2377 |
-
permute_param {
|
2378 |
-
order: 0
|
2379 |
-
order: 2
|
2380 |
-
order: 3
|
2381 |
-
order: 1
|
2382 |
-
}
|
2383 |
-
}
|
2384 |
-
layer {
|
2385 |
-
name: "conv6_3_norm_mbox_conf_flat"
|
2386 |
-
type: "Flatten"
|
2387 |
-
bottom: "conv6_3_norm_mbox_conf_perm"
|
2388 |
-
top: "conv6_3_norm_mbox_conf_flat"
|
2389 |
-
flatten_param {
|
2390 |
-
axis: 1
|
2391 |
-
}
|
2392 |
-
}
|
2393 |
-
layer {
|
2394 |
-
name: "conv6_3_norm_mbox_priorbox"
|
2395 |
-
type: "PriorBox"
|
2396 |
-
bottom: "relu_blob41"
|
2397 |
-
bottom: "data"
|
2398 |
-
top: "conv6_3_norm_mbox_priorbox"
|
2399 |
-
prior_box_param {
|
2400 |
-
min_size: 256.0
|
2401 |
-
min_size: 512.0
|
2402 |
-
clip: false
|
2403 |
-
variance: 0.1
|
2404 |
-
variance: 0.1
|
2405 |
-
variance: 0.2
|
2406 |
-
variance: 0.2
|
2407 |
-
step: 32.0
|
2408 |
-
offset: 0.5
|
2409 |
-
}
|
2410 |
-
}
|
2411 |
-
|
2412 |
-
########################################################
|
2413 |
-
layer {
|
2414 |
-
name: "mbox_loc"
|
2415 |
-
type: "Concat"
|
2416 |
-
bottom: "conv4_3_norm_mbox_loc_flat"
|
2417 |
-
bottom: "conv5_3_norm_mbox_loc_flat"
|
2418 |
-
bottom: "conv6_3_norm_mbox_loc_flat"
|
2419 |
-
top: "mbox_loc"
|
2420 |
-
concat_param {
|
2421 |
-
axis: 1
|
2422 |
-
}
|
2423 |
-
}
|
2424 |
-
layer {
|
2425 |
-
name: "mbox_conf"
|
2426 |
-
type: "Concat"
|
2427 |
-
bottom: "conv4_3_norm_mbox_conf_flat"
|
2428 |
-
bottom: "conv5_3_norm_mbox_conf_flat"
|
2429 |
-
bottom: "conv6_3_norm_mbox_conf_flat"
|
2430 |
-
top: "mbox_conf"
|
2431 |
-
concat_param {
|
2432 |
-
axis: 1
|
2433 |
-
}
|
2434 |
-
}
|
2435 |
-
layer {
|
2436 |
-
name: "mbox_priorbox"
|
2437 |
-
type: "Concat"
|
2438 |
-
bottom: "conv4_3_norm_mbox_priorbox"
|
2439 |
-
bottom: "conv5_3_norm_mbox_priorbox"
|
2440 |
-
bottom: "conv6_3_norm_mbox_priorbox"
|
2441 |
-
top: "mbox_priorbox"
|
2442 |
-
concat_param {
|
2443 |
-
axis: 2
|
2444 |
-
}
|
2445 |
-
}
|
2446 |
-
layer {
|
2447 |
-
name: "mbox_conf_reshape"
|
2448 |
-
type: "Reshape"
|
2449 |
-
bottom: "mbox_conf"
|
2450 |
-
top: "mbox_conf_reshape"
|
2451 |
-
reshape_param {
|
2452 |
-
shape {
|
2453 |
-
dim: 0
|
2454 |
-
dim: -1
|
2455 |
-
dim: 2
|
2456 |
-
}
|
2457 |
-
}
|
2458 |
-
}
|
2459 |
-
layer {
|
2460 |
-
name: "mbox_conf_softmax"
|
2461 |
-
type: "Softmax"
|
2462 |
-
bottom: "mbox_conf_reshape"
|
2463 |
-
top: "mbox_conf_softmax"
|
2464 |
-
softmax_param {
|
2465 |
-
axis: 2
|
2466 |
-
}
|
2467 |
-
}
|
2468 |
-
layer {
|
2469 |
-
name: "mbox_conf_flatten"
|
2470 |
-
type: "Flatten"
|
2471 |
-
bottom: "mbox_conf_softmax"
|
2472 |
-
top: "mbox_conf_flatten"
|
2473 |
-
flatten_param {
|
2474 |
-
axis: 1
|
2475 |
-
}
|
2476 |
-
}
|
2477 |
-
layer {
|
2478 |
-
name: "detection_out"
|
2479 |
-
type: "DetectionOutput"
|
2480 |
-
bottom: "mbox_loc"
|
2481 |
-
bottom: "mbox_conf_flatten"
|
2482 |
-
bottom: "mbox_priorbox"
|
2483 |
-
top: "detection_out"
|
2484 |
-
include {
|
2485 |
-
phase: TEST
|
2486 |
-
}
|
2487 |
-
detection_output_param {
|
2488 |
-
num_classes: 2
|
2489 |
-
share_location: true
|
2490 |
-
background_label_id: 0
|
2491 |
-
nms_param {
|
2492 |
-
nms_threshold: 0.3
|
2493 |
-
top_k: 400
|
2494 |
-
}
|
2495 |
-
code_type: CENTER_SIZE
|
2496 |
-
keep_top_k: 200
|
2497 |
-
confidence_threshold: 0.1
|
2498 |
-
}
|
2499 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/data/config.py
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
# config.py
|
2 |
-
|
3 |
-
cfg = {
|
4 |
-
'name': 'FaceBoxes',
|
5 |
-
#'min_dim': 1024,
|
6 |
-
#'feature_maps': [[32, 32], [16, 16], [8, 8]],
|
7 |
-
# 'aspect_ratios': [[1], [1], [1]],
|
8 |
-
'min_sizes': [[32, 64, 128], [256], [512]],
|
9 |
-
'steps': [32, 64, 128],
|
10 |
-
'variance': [0.1, 0.2],
|
11 |
-
'clip': False,
|
12 |
-
'loc_weight': 2.0,
|
13 |
-
'gpu_train': True
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/layers/__init__.py
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
from .functions import *
|
2 |
-
from .modules import *
|
|
|
|
|
|
face_recognition1/face_detect/layers/functions/prior_box.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
from itertools import product as product
|
3 |
-
import numpy as np
|
4 |
-
from math import ceil
|
5 |
-
|
6 |
-
|
7 |
-
class PriorBox(object):
|
8 |
-
def __init__(self, cfg, image_size=None, phase='train'):
|
9 |
-
super(PriorBox, self).__init__()
|
10 |
-
#self.aspect_ratios = cfg['aspect_ratios']
|
11 |
-
self.min_sizes = cfg['min_sizes']
|
12 |
-
self.steps = cfg['steps']
|
13 |
-
self.clip = cfg['clip']
|
14 |
-
self.image_size = image_size
|
15 |
-
self.feature_maps = [[ceil(self.image_size[0]/step), ceil(self.image_size[1]/step)] for step in self.steps]
|
16 |
-
|
17 |
-
def forward(self):
|
18 |
-
anchors = []
|
19 |
-
for k, f in enumerate(self.feature_maps):
|
20 |
-
min_sizes = self.min_sizes[k]
|
21 |
-
for i, j in product(range(f[0]), range(f[1])):
|
22 |
-
for min_size in min_sizes:
|
23 |
-
s_kx = min_size / self.image_size[1]
|
24 |
-
s_ky = min_size / self.image_size[0]
|
25 |
-
if min_size == 32:
|
26 |
-
dense_cx = [x*self.steps[k]/self.image_size[1] for x in [j+0, j+0.25, j+0.5, j+0.75]]
|
27 |
-
dense_cy = [y*self.steps[k]/self.image_size[0] for y in [i+0, i+0.25, i+0.5, i+0.75]]
|
28 |
-
for cy, cx in product(dense_cy, dense_cx):
|
29 |
-
anchors += [cx, cy, s_kx, s_ky]
|
30 |
-
elif min_size == 64:
|
31 |
-
dense_cx = [x*self.steps[k]/self.image_size[1] for x in [j+0, j+0.5]]
|
32 |
-
dense_cy = [y*self.steps[k]/self.image_size[0] for y in [i+0, i+0.5]]
|
33 |
-
for cy, cx in product(dense_cy, dense_cx):
|
34 |
-
anchors += [cx, cy, s_kx, s_ky]
|
35 |
-
else:
|
36 |
-
cx = (j + 0.5) * self.steps[k] / self.image_size[1]
|
37 |
-
cy = (i + 0.5) * self.steps[k] / self.image_size[0]
|
38 |
-
anchors += [cx, cy, s_kx, s_ky]
|
39 |
-
# back to torch land
|
40 |
-
output = torch.Tensor(anchors).view(-1, 4)
|
41 |
-
if self.clip:
|
42 |
-
output.clamp_(max=1, min=0)
|
43 |
-
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/layers/modules/__init__.py
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
from .multibox_loss import MultiBoxLoss
|
2 |
-
|
3 |
-
__all__ = ['MultiBoxLoss']
|
|
|
|
|
|
|
|
face_recognition1/face_detect/layers/modules/multibox_loss.py
DELETED
@@ -1,108 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import torch.nn as nn
|
3 |
-
import torch.nn.functional as F
|
4 |
-
from torch.autograd import Variable
|
5 |
-
from utils.box_utils import match, log_sum_exp
|
6 |
-
from data.config import cfg
|
7 |
-
GPU = cfg['gpu_train']
|
8 |
-
|
9 |
-
class MultiBoxLoss(nn.Module):
|
10 |
-
"""SSD Weighted Loss Function
|
11 |
-
Compute Targets:
|
12 |
-
1) Produce Confidence Target Indices by matching ground truth boxes
|
13 |
-
with (default) 'priorboxes' that have jaccard index > threshold parameter
|
14 |
-
(default threshold: 0.5).
|
15 |
-
2) Produce localization target by 'encoding' variance into offsets of ground
|
16 |
-
truth boxes and their matched 'priorboxes'.
|
17 |
-
3) Hard negative mining to filter the excessive number of negative examples
|
18 |
-
that comes with using a large number of default bounding boxes.
|
19 |
-
(default negative:positive ratio 3:1)
|
20 |
-
Objective Loss:
|
21 |
-
L(x,c,l,g) = (Lconf(x, c) + αLloc(x,l,g)) / N
|
22 |
-
Where, Lconf is the CrossEntropy Loss and Lloc is the SmoothL1 Loss
|
23 |
-
weighted by α which is set to 1 by cross val.
|
24 |
-
Args:
|
25 |
-
c: class confidences,
|
26 |
-
l: predicted boxes,
|
27 |
-
g: ground truth boxes
|
28 |
-
N: number of matched default boxes
|
29 |
-
See: https://arxiv.org/pdf/1512.02325.pdf for more details.
|
30 |
-
"""
|
31 |
-
|
32 |
-
def __init__(self, num_classes, overlap_thresh, prior_for_matching, bkg_label, neg_mining, neg_pos, neg_overlap, encode_target):
|
33 |
-
super(MultiBoxLoss, self).__init__()
|
34 |
-
self.num_classes = num_classes
|
35 |
-
self.threshold = overlap_thresh
|
36 |
-
self.background_label = bkg_label
|
37 |
-
self.encode_target = encode_target
|
38 |
-
self.use_prior_for_matching = prior_for_matching
|
39 |
-
self.do_neg_mining = neg_mining
|
40 |
-
self.negpos_ratio = neg_pos
|
41 |
-
self.neg_overlap = neg_overlap
|
42 |
-
self.variance = [0.1, 0.2]
|
43 |
-
|
44 |
-
def forward(self, predictions, priors, targets):
|
45 |
-
"""Multibox Loss
|
46 |
-
Args:
|
47 |
-
predictions (tuple): A tuple containing loc preds, conf preds,
|
48 |
-
and prior boxes from SSD net.
|
49 |
-
conf shape: torch.size(batch_size,num_priors,num_classes)
|
50 |
-
loc shape: torch.size(batch_size,num_priors,4)
|
51 |
-
priors shape: torch.size(num_priors,4)
|
52 |
-
|
53 |
-
ground_truth (tensor): Ground truth boxes and labels for a batch,
|
54 |
-
shape: [batch_size,num_objs,5] (last idx is the label).
|
55 |
-
"""
|
56 |
-
|
57 |
-
loc_data, conf_data = predictions
|
58 |
-
priors = priors
|
59 |
-
num = loc_data.size(0)
|
60 |
-
num_priors = (priors.size(0))
|
61 |
-
|
62 |
-
# match priors (default boxes) and ground truth boxes
|
63 |
-
loc_t = torch.Tensor(num, num_priors, 4)
|
64 |
-
conf_t = torch.LongTensor(num, num_priors)
|
65 |
-
for idx in range(num):
|
66 |
-
truths = targets[idx][:, :-1].data
|
67 |
-
labels = targets[idx][:, -1].data
|
68 |
-
defaults = priors.data
|
69 |
-
match(self.threshold, truths, defaults, self.variance, labels, loc_t, conf_t, idx)
|
70 |
-
if GPU:
|
71 |
-
loc_t = loc_t.cuda()
|
72 |
-
conf_t = conf_t.cuda()
|
73 |
-
|
74 |
-
pos = conf_t > 0
|
75 |
-
|
76 |
-
# Localization Loss (Smooth L1)
|
77 |
-
# Shape: [batch,num_priors,4]
|
78 |
-
pos_idx = pos.unsqueeze(pos.dim()).expand_as(loc_data)
|
79 |
-
loc_p = loc_data[pos_idx].view(-1, 4)
|
80 |
-
loc_t = loc_t[pos_idx].view(-1, 4)
|
81 |
-
loss_l = F.smooth_l1_loss(loc_p, loc_t, reduction='sum')
|
82 |
-
|
83 |
-
# Compute max conf across batch for hard negative mining
|
84 |
-
batch_conf = conf_data.view(-1, self.num_classes)
|
85 |
-
loss_c = log_sum_exp(batch_conf) - batch_conf.gather(1, conf_t.view(-1, 1))
|
86 |
-
|
87 |
-
# Hard Negative Mining
|
88 |
-
loss_c[pos.view(-1, 1)] = 0 # filter out pos boxes for now
|
89 |
-
loss_c = loss_c.view(num, -1)
|
90 |
-
_, loss_idx = loss_c.sort(1, descending=True)
|
91 |
-
_, idx_rank = loss_idx.sort(1)
|
92 |
-
num_pos = pos.long().sum(1, keepdim=True)
|
93 |
-
num_neg = torch.clamp(self.negpos_ratio*num_pos, max=pos.size(1)-1)
|
94 |
-
neg = idx_rank < num_neg.expand_as(idx_rank)
|
95 |
-
|
96 |
-
# Confidence Loss Including Positive and Negative Examples
|
97 |
-
pos_idx = pos.unsqueeze(2).expand_as(conf_data)
|
98 |
-
neg_idx = neg.unsqueeze(2).expand_as(conf_data)
|
99 |
-
conf_p = conf_data[(pos_idx+neg_idx).gt(0)].view(-1,self.num_classes)
|
100 |
-
targets_weighted = conf_t[(pos+neg).gt(0)]
|
101 |
-
loss_c = F.cross_entropy(conf_p, targets_weighted, reduction='sum')
|
102 |
-
|
103 |
-
# Sum of losses: L(x,c,l,g) = (Lconf(x, c) + αLloc(x,l,g)) / N
|
104 |
-
N = max(num_pos.data.sum().float(), 1)
|
105 |
-
loss_l /= N
|
106 |
-
loss_c /= N
|
107 |
-
|
108 |
-
return loss_l, loss_c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/models/__init__.py
DELETED
File without changes
|
face_recognition1/face_detect/models/faceboxes.py
DELETED
@@ -1,149 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import torch.nn as nn
|
3 |
-
import torch.nn.functional as F
|
4 |
-
|
5 |
-
|
6 |
-
class BasicConv2d(nn.Module):
|
7 |
-
|
8 |
-
def __init__(self, in_channels, out_channels, **kwargs):
|
9 |
-
super(BasicConv2d, self).__init__()
|
10 |
-
self.conv = nn.Conv2d(in_channels, out_channels, bias=False, **kwargs)
|
11 |
-
self.bn = nn.BatchNorm2d(out_channels, eps=1e-5)
|
12 |
-
|
13 |
-
def forward(self, x):
|
14 |
-
x = self.conv(x)
|
15 |
-
x = self.bn(x)
|
16 |
-
return F.relu(x, inplace=True)
|
17 |
-
|
18 |
-
|
19 |
-
class Inception(nn.Module):
|
20 |
-
|
21 |
-
def __init__(self):
|
22 |
-
super(Inception, self).__init__()
|
23 |
-
self.branch1x1 = BasicConv2d(128, 32, kernel_size=1, padding=0)
|
24 |
-
self.branch1x1_2 = BasicConv2d(128, 32, kernel_size=1, padding=0)
|
25 |
-
self.branch3x3_reduce = BasicConv2d(128, 24, kernel_size=1, padding=0)
|
26 |
-
self.branch3x3 = BasicConv2d(24, 32, kernel_size=3, padding=1)
|
27 |
-
self.branch3x3_reduce_2 = BasicConv2d(128, 24, kernel_size=1, padding=0)
|
28 |
-
self.branch3x3_2 = BasicConv2d(24, 32, kernel_size=3, padding=1)
|
29 |
-
self.branch3x3_3 = BasicConv2d(32, 32, kernel_size=3, padding=1)
|
30 |
-
|
31 |
-
def forward(self, x):
|
32 |
-
branch1x1 = self.branch1x1(x)
|
33 |
-
|
34 |
-
branch1x1_pool = F.avg_pool2d(x, kernel_size=3, stride=1, padding=1)
|
35 |
-
branch1x1_2 = self.branch1x1_2(branch1x1_pool)
|
36 |
-
|
37 |
-
branch3x3_reduce = self.branch3x3_reduce(x)
|
38 |
-
branch3x3 = self.branch3x3(branch3x3_reduce)
|
39 |
-
|
40 |
-
branch3x3_reduce_2 = self.branch3x3_reduce_2(x)
|
41 |
-
branch3x3_2 = self.branch3x3_2(branch3x3_reduce_2)
|
42 |
-
branch3x3_3 = self.branch3x3_3(branch3x3_2)
|
43 |
-
|
44 |
-
outputs = [branch1x1, branch1x1_2, branch3x3, branch3x3_3]
|
45 |
-
return torch.cat(outputs, 1)
|
46 |
-
|
47 |
-
|
48 |
-
class CRelu(nn.Module):
|
49 |
-
|
50 |
-
def __init__(self, in_channels, out_channels, **kwargs):
|
51 |
-
super(CRelu, self).__init__()
|
52 |
-
self.conv = nn.Conv2d(in_channels, out_channels, bias=False, **kwargs)
|
53 |
-
self.bn = nn.BatchNorm2d(out_channels, eps=1e-5)
|
54 |
-
|
55 |
-
def forward(self, x):
|
56 |
-
x = self.conv(x)
|
57 |
-
x = self.bn(x)
|
58 |
-
x = torch.cat([x, -x], 1)
|
59 |
-
x = F.relu(x, inplace=True)
|
60 |
-
return x
|
61 |
-
|
62 |
-
|
63 |
-
class FaceBoxes(nn.Module):
|
64 |
-
|
65 |
-
def __init__(self, phase, size, num_classes):
|
66 |
-
super(FaceBoxes, self).__init__()
|
67 |
-
self.phase = phase
|
68 |
-
self.num_classes = num_classes
|
69 |
-
self.size = size
|
70 |
-
|
71 |
-
self.conv1 = CRelu(3, 24, kernel_size=7, stride=4, padding=3)
|
72 |
-
self.conv2 = CRelu(48, 64, kernel_size=5, stride=2, padding=2)
|
73 |
-
|
74 |
-
self.inception1 = Inception()
|
75 |
-
self.inception2 = Inception()
|
76 |
-
self.inception3 = Inception()
|
77 |
-
|
78 |
-
self.conv3_1 = BasicConv2d(128, 128, kernel_size=1, stride=1, padding=0)
|
79 |
-
self.conv3_2 = BasicConv2d(128, 256, kernel_size=3, stride=2, padding=1)
|
80 |
-
|
81 |
-
self.conv4_1 = BasicConv2d(256, 128, kernel_size=1, stride=1, padding=0)
|
82 |
-
self.conv4_2 = BasicConv2d(128, 256, kernel_size=3, stride=2, padding=1)
|
83 |
-
|
84 |
-
self.loc, self.conf = self.multibox(self.num_classes)
|
85 |
-
|
86 |
-
if self.phase == 'test':
|
87 |
-
self.softmax = nn.Softmax(dim=-1)
|
88 |
-
|
89 |
-
if self.phase == 'train':
|
90 |
-
for m in self.modules():
|
91 |
-
if isinstance(m, nn.Conv2d):
|
92 |
-
if m.bias is not None:
|
93 |
-
nn.init.xavier_normal_(m.weight.data)
|
94 |
-
m.bias.data.fill_(0.02)
|
95 |
-
else:
|
96 |
-
m.weight.data.normal_(0, 0.01)
|
97 |
-
elif isinstance(m, nn.BatchNorm2d):
|
98 |
-
m.weight.data.fill_(1)
|
99 |
-
m.bias.data.zero_()
|
100 |
-
|
101 |
-
def multibox(self, num_classes):
|
102 |
-
loc_layers = []
|
103 |
-
conf_layers = []
|
104 |
-
loc_layers += [nn.Conv2d(128, 21 * 4, kernel_size=3, padding=1)]
|
105 |
-
conf_layers += [nn.Conv2d(128, 21 * num_classes, kernel_size=3, padding=1)]
|
106 |
-
loc_layers += [nn.Conv2d(256, 1 * 4, kernel_size=3, padding=1)]
|
107 |
-
conf_layers += [nn.Conv2d(256, 1 * num_classes, kernel_size=3, padding=1)]
|
108 |
-
loc_layers += [nn.Conv2d(256, 1 * 4, kernel_size=3, padding=1)]
|
109 |
-
conf_layers += [nn.Conv2d(256, 1 * num_classes, kernel_size=3, padding=1)]
|
110 |
-
return nn.Sequential(*loc_layers), nn.Sequential(*conf_layers)
|
111 |
-
|
112 |
-
def forward(self, x):
|
113 |
-
|
114 |
-
detection_sources = list()
|
115 |
-
loc = list()
|
116 |
-
conf = list()
|
117 |
-
|
118 |
-
x = self.conv1(x)
|
119 |
-
x = F.max_pool2d(x, kernel_size=3, stride=2, padding=1)
|
120 |
-
x = self.conv2(x)
|
121 |
-
x = F.max_pool2d(x, kernel_size=3, stride=2, padding=1)
|
122 |
-
x = self.inception1(x)
|
123 |
-
x = self.inception2(x)
|
124 |
-
x = self.inception3(x)
|
125 |
-
detection_sources.append(x)
|
126 |
-
|
127 |
-
x = self.conv3_1(x)
|
128 |
-
x = self.conv3_2(x)
|
129 |
-
detection_sources.append(x)
|
130 |
-
|
131 |
-
x = self.conv4_1(x)
|
132 |
-
x = self.conv4_2(x)
|
133 |
-
detection_sources.append(x)
|
134 |
-
|
135 |
-
for (x, l, c) in zip(detection_sources, self.loc, self.conf):
|
136 |
-
loc.append(l(x).permute(0, 2, 3, 1).contiguous())
|
137 |
-
conf.append(c(x).permute(0, 2, 3, 1).contiguous())
|
138 |
-
|
139 |
-
loc = torch.cat([o.view(o.size(0), -1) for o in loc], 1)
|
140 |
-
conf = torch.cat([o.view(o.size(0), -1) for o in conf], 1)
|
141 |
-
|
142 |
-
if self.phase == "test":
|
143 |
-
output = (loc.view(loc.size(0), -1, 4),
|
144 |
-
self.softmax(conf.view(conf.size(0), -1, self.num_classes)))
|
145 |
-
else:
|
146 |
-
output = (loc.view(loc.size(0), -1, 4),
|
147 |
-
conf.view(conf.size(0), -1, self.num_classes))
|
148 |
-
|
149 |
-
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/models/voc-model-labels.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
BACKGROUND
|
2 |
-
face
|
|
|
|
|
|
face_recognition1/face_detect/test.py
DELETED
@@ -1,197 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import sys
|
3 |
-
sys.path.append(os.path.dirname(__file__))
|
4 |
-
|
5 |
-
import cv2
|
6 |
-
import math
|
7 |
-
import torch
|
8 |
-
import torch.backends.cudnn as cudnn
|
9 |
-
import numpy as np
|
10 |
-
from data.config import cfg
|
11 |
-
from layers.functions.prior_box import PriorBox
|
12 |
-
from utils.nms_wrapper import nms
|
13 |
-
from models.faceboxes import FaceBoxes
|
14 |
-
from utils.box_utils import decode
|
15 |
-
from utils.timer import Timer
|
16 |
-
|
17 |
-
trained_model = os.path.join(os.path.dirname(__file__), './checkpoints/FaceBoxesProd.pth')
|
18 |
-
save_folder = 'eval'
|
19 |
-
dataset = 'Custom'
|
20 |
-
confidence_threshold = 0.2
|
21 |
-
top_k = 5000
|
22 |
-
nms_threshold = 0.3
|
23 |
-
keep_top_k = 750
|
24 |
-
show_image = True
|
25 |
-
vis_thres = 0.5
|
26 |
-
|
27 |
-
|
28 |
-
def check_keys(model, pretrained_state_dict):
|
29 |
-
ckpt_keys = set(pretrained_state_dict.keys())
|
30 |
-
model_keys = set(model.state_dict().keys())
|
31 |
-
used_pretrained_keys = model_keys & ckpt_keys
|
32 |
-
unused_pretrained_keys = ckpt_keys - model_keys
|
33 |
-
missing_keys = model_keys - ckpt_keys
|
34 |
-
print('Missing keys:{}'.format(len(missing_keys)))
|
35 |
-
print('Unused checkpoint keys:{}'.format(len(unused_pretrained_keys)))
|
36 |
-
print('Used keys:{}'.format(len(used_pretrained_keys)))
|
37 |
-
assert len(used_pretrained_keys) > 0, 'load NONE from pretrained checkpoint'
|
38 |
-
return True
|
39 |
-
|
40 |
-
|
41 |
-
def remove_prefix(state_dict, prefix):
|
42 |
-
""" Old style model is stored with all names of parameters sharing common prefix 'module.' """
|
43 |
-
print('remove prefix \'{}\''.format(prefix))
|
44 |
-
f = lambda x: x.split(prefix, 1)[-1] if x.startswith(prefix) else x
|
45 |
-
return {f(key): value for key, value in state_dict.items()}
|
46 |
-
|
47 |
-
|
48 |
-
def load_model(model, pretrained_path, device):
|
49 |
-
print('Loading pretrained model from {}'.format(pretrained_path))
|
50 |
-
pretrained_dict = torch.load(pretrained_path, map_location=device)
|
51 |
-
|
52 |
-
if "state_dict" in pretrained_dict.keys():
|
53 |
-
pretrained_dict = remove_prefix(pretrained_dict['state_dict'], 'module.')
|
54 |
-
else:
|
55 |
-
pretrained_dict = remove_prefix(pretrained_dict, 'module.')
|
56 |
-
check_keys(model, pretrained_dict)
|
57 |
-
model.load_state_dict(pretrained_dict, strict=False)
|
58 |
-
return model
|
59 |
-
|
60 |
-
|
61 |
-
torch.set_grad_enabled(False)
|
62 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
63 |
-
net = FaceBoxes(phase='test', size=None, num_classes=2)
|
64 |
-
net = load_model(net, trained_model, device)
|
65 |
-
net.eval()
|
66 |
-
cudnn.benchmark = True
|
67 |
-
net = net.to(device)
|
68 |
-
|
69 |
-
|
70 |
-
def get_bbox(orig_image):
|
71 |
-
# testing scale
|
72 |
-
resize = 0.5
|
73 |
-
|
74 |
-
_t = {'forward_pass': Timer(), 'misc': Timer()}
|
75 |
-
|
76 |
-
img_raw = orig_image
|
77 |
-
img = np.float32(img_raw)
|
78 |
-
if resize != 1:
|
79 |
-
img = cv2.resize(img, None, None, fx=resize, fy=resize, interpolation=cv2.INTER_LINEAR)
|
80 |
-
im_height, im_width, _ = img.shape
|
81 |
-
scale = torch.Tensor([img.shape[1], img.shape[0], img.shape[1], img.shape[0]])
|
82 |
-
img -= (104, 117, 123)
|
83 |
-
img = img.transpose(2, 0, 1)
|
84 |
-
img = torch.from_numpy(img).unsqueeze(0)
|
85 |
-
img = img.to(device)
|
86 |
-
scale = scale.to(device)
|
87 |
-
|
88 |
-
_t['forward_pass'].tic()
|
89 |
-
loc, conf = net(img) # forward pass
|
90 |
-
_t['forward_pass'].toc()
|
91 |
-
_t['misc'].tic()
|
92 |
-
priorbox = PriorBox(cfg, image_size=(im_height, im_width))
|
93 |
-
priors = priorbox.forward()
|
94 |
-
priors = priors.to(device)
|
95 |
-
prior_data = priors.data
|
96 |
-
boxes = decode(loc.data.squeeze(0), prior_data, cfg['variance'])
|
97 |
-
boxes = boxes * scale / resize
|
98 |
-
boxes = boxes.cpu().numpy()
|
99 |
-
scores = conf.squeeze(0).data.cpu().numpy()[:, 1]
|
100 |
-
|
101 |
-
# ignore low scores
|
102 |
-
inds = np.where(scores > confidence_threshold)[0]
|
103 |
-
boxes = boxes[inds]
|
104 |
-
scores = scores[inds]
|
105 |
-
|
106 |
-
# keep top-K before NMS
|
107 |
-
order = scores.argsort()[::-1][:top_k]
|
108 |
-
boxes = boxes[order]
|
109 |
-
scores = scores[order]
|
110 |
-
|
111 |
-
# do NMS
|
112 |
-
dets = np.hstack((boxes, scores[:, np.newaxis])).astype(np.float32, copy=False)
|
113 |
-
#keep = py_cpu_nms(dets, nms_threshold)
|
114 |
-
keep = nms(dets, nms_threshold, force_cpu=True)
|
115 |
-
dets = dets[keep, :]
|
116 |
-
|
117 |
-
# keep top-K faster NMS
|
118 |
-
dets = dets[:keep_top_k, :]
|
119 |
-
_t['misc'].toc()
|
120 |
-
|
121 |
-
boxes, scores = [], []
|
122 |
-
for k in range(dets.shape[0]):
|
123 |
-
xmin = dets[k, 0]
|
124 |
-
ymin = dets[k, 1]
|
125 |
-
xmax = dets[k, 2]
|
126 |
-
ymax = dets[k, 3]
|
127 |
-
ymin += 0.2 * (ymax - ymin + 1)
|
128 |
-
score = dets[k, 4]
|
129 |
-
boxes.append([int(xmin), int(ymin), int(xmax - xmin), int(ymax - ymin)])
|
130 |
-
scores.append(score)
|
131 |
-
|
132 |
-
max_score = 0.0
|
133 |
-
final_box = None
|
134 |
-
for i, score in enumerate(scores):
|
135 |
-
if max_score < score:
|
136 |
-
max_score = score
|
137 |
-
final_box = boxes[i]
|
138 |
-
|
139 |
-
return final_box
|
140 |
-
|
141 |
-
|
142 |
-
class Detection:
|
143 |
-
def __init__(self):
|
144 |
-
src_dir = os.path.dirname(__file__)
|
145 |
-
if not os.path.exists(os.path.join(src_dir, "checkpoints")):
|
146 |
-
os.makedirs(os.path.join(src_dir, "checkpoints"))
|
147 |
-
|
148 |
-
caffemodel = os.path.join(src_dir, "checkpoints/Widerface-RetinaFace.caffemodel")
|
149 |
-
deploy = os.path.join(src_dir, "checkpoints/deploy.prototxt")
|
150 |
-
|
151 |
-
self.detector = cv2.dnn.readNetFromCaffe(deploy, caffemodel)
|
152 |
-
self.detector_confidence = 0.6
|
153 |
-
|
154 |
-
def get_bbox(self, img):
|
155 |
-
height, width = img.shape[0], img.shape[1]
|
156 |
-
aspect_ratio = width / height
|
157 |
-
if img.shape[1] * img.shape[0] >= 192 * 192:
|
158 |
-
img = cv2.resize(img,
|
159 |
-
(int(192 * math.sqrt(aspect_ratio)),
|
160 |
-
int(192 / math.sqrt(aspect_ratio))), interpolation=cv2.INTER_LINEAR)
|
161 |
-
|
162 |
-
blob = cv2.dnn.blobFromImage(img, 1, mean=(104, 117, 123))
|
163 |
-
self.detector.setInput(blob, 'data')
|
164 |
-
out = self.detector.forward('detection_out').squeeze()
|
165 |
-
max_conf_index = np.argmax(out[:, 2])
|
166 |
-
left, top, right, bottom = out[max_conf_index, 3]*width, out[max_conf_index, 4]*height, \
|
167 |
-
out[max_conf_index, 5]*width, out[max_conf_index, 6]*height
|
168 |
-
|
169 |
-
if right == left or bottom == top:
|
170 |
-
return None
|
171 |
-
|
172 |
-
bbox = [int(left), int(top), int(right-left+1), int(bottom-top+1)]
|
173 |
-
return bbox
|
174 |
-
|
175 |
-
def check_face(self):
|
176 |
-
pass
|
177 |
-
|
178 |
-
|
179 |
-
if __name__ == '__main__':
|
180 |
-
|
181 |
-
# image = cv2.imread('arun_2.jpg')
|
182 |
-
|
183 |
-
# box = get_bbox(image)
|
184 |
-
# cv2.rectangle(image, (box[0], box[1]), (box[2], box[3]), (0, 0, 255), 2)
|
185 |
-
#
|
186 |
-
src_dir = 'D:/19.Database/office_angled_db'
|
187 |
-
dst_dir = 'D:/19.Database/office_angled_db_result'
|
188 |
-
detector = Detection()
|
189 |
-
|
190 |
-
for file in os.listdir(src_dir):
|
191 |
-
image1 = cv2.imread(os.path.join(src_dir, file))
|
192 |
-
box = detector.get_bbox(image1)
|
193 |
-
if box:
|
194 |
-
cv2.rectangle(image1, (box[0], box[1]), (box[0] + box[2], box[1] + box[3]), (0, 0, 255), 5)
|
195 |
-
|
196 |
-
cv2.imwrite(os.path.join(dst_dir, file), image1)
|
197 |
-
# cv2.waitKey(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/__init__.py
DELETED
File without changes
|
face_recognition1/face_detect/utils/box_utils.py
DELETED
@@ -1,276 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
import numpy as np
|
3 |
-
|
4 |
-
|
5 |
-
def point_form(boxes):
|
6 |
-
""" Convert prior_boxes to (xmin, ymin, xmax, ymax)
|
7 |
-
representation for comparison to point form ground truth data.
|
8 |
-
Args:
|
9 |
-
boxes: (tensor) center-size default boxes from priorbox layers.
|
10 |
-
Return:
|
11 |
-
boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.
|
12 |
-
"""
|
13 |
-
return torch.cat((boxes[:, :2] - boxes[:, 2:]/2, # xmin, ymin
|
14 |
-
boxes[:, :2] + boxes[:, 2:]/2), 1) # xmax, ymax
|
15 |
-
|
16 |
-
|
17 |
-
def center_size(boxes):
|
18 |
-
""" Convert prior_boxes to (cx, cy, w, h)
|
19 |
-
representation for comparison to center-size form ground truth data.
|
20 |
-
Args:
|
21 |
-
boxes: (tensor) point_form boxes
|
22 |
-
Return:
|
23 |
-
boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.
|
24 |
-
"""
|
25 |
-
return torch.cat((boxes[:, 2:] + boxes[:, :2])/2, # cx, cy
|
26 |
-
boxes[:, 2:] - boxes[:, :2], 1) # w, h
|
27 |
-
|
28 |
-
|
29 |
-
def intersect(box_a, box_b):
|
30 |
-
""" We resize both tensors to [A,B,2] without new malloc:
|
31 |
-
[A,2] -> [A,1,2] -> [A,B,2]
|
32 |
-
[B,2] -> [1,B,2] -> [A,B,2]
|
33 |
-
Then we compute the area of intersect between box_a and box_b.
|
34 |
-
Args:
|
35 |
-
box_a: (tensor) bounding boxes, Shape: [A,4].
|
36 |
-
box_b: (tensor) bounding boxes, Shape: [B,4].
|
37 |
-
Return:
|
38 |
-
(tensor) intersection area, Shape: [A,B].
|
39 |
-
"""
|
40 |
-
A = box_a.size(0)
|
41 |
-
B = box_b.size(0)
|
42 |
-
max_xy = torch.min(box_a[:, 2:].unsqueeze(1).expand(A, B, 2),
|
43 |
-
box_b[:, 2:].unsqueeze(0).expand(A, B, 2))
|
44 |
-
min_xy = torch.max(box_a[:, :2].unsqueeze(1).expand(A, B, 2),
|
45 |
-
box_b[:, :2].unsqueeze(0).expand(A, B, 2))
|
46 |
-
inter = torch.clamp((max_xy - min_xy), min=0)
|
47 |
-
return inter[:, :, 0] * inter[:, :, 1]
|
48 |
-
|
49 |
-
|
50 |
-
def jaccard(box_a, box_b):
|
51 |
-
"""Compute the jaccard overlap of two sets of boxes. The jaccard overlap
|
52 |
-
is simply the intersection over union of two boxes. Here we operate on
|
53 |
-
ground truth boxes and default boxes.
|
54 |
-
E.g.:
|
55 |
-
A ∩ B / A ∪ B = A ∩ B / (area(A) + area(B) - A ∩ B)
|
56 |
-
Args:
|
57 |
-
box_a: (tensor) Ground truth bounding boxes, Shape: [num_objects,4]
|
58 |
-
box_b: (tensor) Prior boxes from priorbox layers, Shape: [num_priors,4]
|
59 |
-
Return:
|
60 |
-
jaccard overlap: (tensor) Shape: [box_a.size(0), box_b.size(0)]
|
61 |
-
"""
|
62 |
-
inter = intersect(box_a, box_b)
|
63 |
-
area_a = ((box_a[:, 2]-box_a[:, 0]) *
|
64 |
-
(box_a[:, 3]-box_a[:, 1])).unsqueeze(1).expand_as(inter) # [A,B]
|
65 |
-
area_b = ((box_b[:, 2]-box_b[:, 0]) *
|
66 |
-
(box_b[:, 3]-box_b[:, 1])).unsqueeze(0).expand_as(inter) # [A,B]
|
67 |
-
union = area_a + area_b - inter
|
68 |
-
return inter / union # [A,B]
|
69 |
-
|
70 |
-
|
71 |
-
def matrix_iou(a, b):
|
72 |
-
"""
|
73 |
-
return iou of a and b, numpy version for data augenmentation
|
74 |
-
"""
|
75 |
-
lt = np.maximum(a[:, np.newaxis, :2], b[:, :2])
|
76 |
-
rb = np.minimum(a[:, np.newaxis, 2:], b[:, 2:])
|
77 |
-
|
78 |
-
area_i = np.prod(rb - lt, axis=2) * (lt < rb).all(axis=2)
|
79 |
-
area_a = np.prod(a[:, 2:] - a[:, :2], axis=1)
|
80 |
-
area_b = np.prod(b[:, 2:] - b[:, :2], axis=1)
|
81 |
-
return area_i / (area_a[:, np.newaxis] + area_b - area_i)
|
82 |
-
|
83 |
-
|
84 |
-
def matrix_iof(a, b):
|
85 |
-
"""
|
86 |
-
return iof of a and b, numpy version for data augenmentation
|
87 |
-
"""
|
88 |
-
lt = np.maximum(a[:, np.newaxis, :2], b[:, :2])
|
89 |
-
rb = np.minimum(a[:, np.newaxis, 2:], b[:, 2:])
|
90 |
-
|
91 |
-
area_i = np.prod(rb - lt, axis=2) * (lt < rb).all(axis=2)
|
92 |
-
area_a = np.prod(a[:, 2:] - a[:, :2], axis=1)
|
93 |
-
return area_i / np.maximum(area_a[:, np.newaxis], 1)
|
94 |
-
|
95 |
-
|
96 |
-
def match(threshold, truths, priors, variances, labels, loc_t, conf_t, idx):
|
97 |
-
"""Match each prior box with the ground truth box of the highest jaccard
|
98 |
-
overlap, encode the bounding boxes, then return the matched indices
|
99 |
-
corresponding to both confidence and location preds.
|
100 |
-
Args:
|
101 |
-
threshold: (float) The overlap threshold used when mathing boxes.
|
102 |
-
truths: (tensor) Ground truth boxes, Shape: [num_obj, num_priors].
|
103 |
-
priors: (tensor) Prior boxes from priorbox layers, Shape: [n_priors,4].
|
104 |
-
variances: (tensor) Variances corresponding to each prior coord,
|
105 |
-
Shape: [num_priors, 4].
|
106 |
-
labels: (tensor) All the class labels for the image, Shape: [num_obj].
|
107 |
-
loc_t: (tensor) Tensor to be filled w/ endcoded location targets.
|
108 |
-
conf_t: (tensor) Tensor to be filled w/ matched indices for conf preds.
|
109 |
-
idx: (int) current batch index
|
110 |
-
Return:
|
111 |
-
The matched indices corresponding to 1)location and 2)confidence preds.
|
112 |
-
"""
|
113 |
-
# jaccard index
|
114 |
-
overlaps = jaccard(
|
115 |
-
truths,
|
116 |
-
point_form(priors)
|
117 |
-
)
|
118 |
-
# (Bipartite Matching)
|
119 |
-
# [1,num_objects] best prior for each ground truth
|
120 |
-
best_prior_overlap, best_prior_idx = overlaps.max(1, keepdim=True)
|
121 |
-
|
122 |
-
# ignore hard gt
|
123 |
-
valid_gt_idx = best_prior_overlap[:, 0] >= 0.2
|
124 |
-
best_prior_idx_filter = best_prior_idx[valid_gt_idx, :]
|
125 |
-
if best_prior_idx_filter.shape[0] <= 0:
|
126 |
-
loc_t[idx] = 0
|
127 |
-
conf_t[idx] = 0
|
128 |
-
return
|
129 |
-
|
130 |
-
# [1,num_priors] best ground truth for each prior
|
131 |
-
best_truth_overlap, best_truth_idx = overlaps.max(0, keepdim=True)
|
132 |
-
best_truth_idx.squeeze_(0)
|
133 |
-
best_truth_overlap.squeeze_(0)
|
134 |
-
best_prior_idx.squeeze_(1)
|
135 |
-
best_prior_idx_filter.squeeze_(1)
|
136 |
-
best_prior_overlap.squeeze_(1)
|
137 |
-
best_truth_overlap.index_fill_(0, best_prior_idx_filter, 2) # ensure best prior
|
138 |
-
# TODO refactor: index best_prior_idx with long tensor
|
139 |
-
# ensure every gt matches with its prior of max overlap
|
140 |
-
for j in range(best_prior_idx.size(0)):
|
141 |
-
best_truth_idx[best_prior_idx[j]] = j
|
142 |
-
matches = truths[best_truth_idx] # Shape: [num_priors,4]
|
143 |
-
conf = labels[best_truth_idx] # Shape: [num_priors]
|
144 |
-
conf[best_truth_overlap < threshold] = 0 # label as background
|
145 |
-
loc = encode(matches, priors, variances)
|
146 |
-
loc_t[idx] = loc # [num_priors,4] encoded offsets to learn
|
147 |
-
conf_t[idx] = conf # [num_priors] top class label for each prior
|
148 |
-
|
149 |
-
|
150 |
-
def encode(matched, priors, variances):
|
151 |
-
"""Encode the variances from the priorbox layers into the ground truth boxes
|
152 |
-
we have matched (based on jaccard overlap) with the prior boxes.
|
153 |
-
Args:
|
154 |
-
matched: (tensor) Coords of ground truth for each prior in point-form
|
155 |
-
Shape: [num_priors, 4].
|
156 |
-
priors: (tensor) Prior boxes in center-offset form
|
157 |
-
Shape: [num_priors,4].
|
158 |
-
variances: (list[float]) Variances of priorboxes
|
159 |
-
Return:
|
160 |
-
encoded boxes (tensor), Shape: [num_priors, 4]
|
161 |
-
"""
|
162 |
-
|
163 |
-
# dist b/t match center and prior's center
|
164 |
-
g_cxcy = (matched[:, :2] + matched[:, 2:])/2 - priors[:, :2]
|
165 |
-
# encode variance
|
166 |
-
g_cxcy /= (variances[0] * priors[:, 2:])
|
167 |
-
# match wh / prior wh
|
168 |
-
g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
|
169 |
-
g_wh = torch.log(g_wh) / variances[1]
|
170 |
-
# return target for smooth_l1_loss
|
171 |
-
return torch.cat([g_cxcy, g_wh], 1) # [num_priors,4]
|
172 |
-
|
173 |
-
|
174 |
-
# Adapted from https://github.com/Hakuyume/chainer-ssd
|
175 |
-
def decode(loc, priors, variances):
|
176 |
-
"""Decode locations from predictions using priors to undo
|
177 |
-
the encoding we did for offset regression at train time.
|
178 |
-
Args:
|
179 |
-
loc (tensor): location predictions for loc layers,
|
180 |
-
Shape: [num_priors,4]
|
181 |
-
priors (tensor): Prior boxes in center-offset form.
|
182 |
-
Shape: [num_priors,4].
|
183 |
-
variances: (list[float]) Variances of priorboxes
|
184 |
-
Return:
|
185 |
-
decoded bounding box predictions
|
186 |
-
"""
|
187 |
-
|
188 |
-
boxes = torch.cat((
|
189 |
-
priors[:, :2] + loc[:, :2] * variances[0] * priors[:, 2:],
|
190 |
-
priors[:, 2:] * torch.exp(loc[:, 2:] * variances[1])), 1)
|
191 |
-
boxes[:, :2] -= boxes[:, 2:] / 2
|
192 |
-
boxes[:, 2:] += boxes[:, :2]
|
193 |
-
return boxes
|
194 |
-
|
195 |
-
|
196 |
-
def log_sum_exp(x):
|
197 |
-
"""Utility function for computing log_sum_exp while determining
|
198 |
-
This will be used to determine unaveraged confidence loss across
|
199 |
-
all examples in a batch.
|
200 |
-
Args:
|
201 |
-
x (Variable(tensor)): conf_preds from conf layers
|
202 |
-
"""
|
203 |
-
x_max = x.data.max()
|
204 |
-
return torch.log(torch.sum(torch.exp(x-x_max), 1, keepdim=True)) + x_max
|
205 |
-
|
206 |
-
|
207 |
-
# Original author: Francisco Massa:
|
208 |
-
# https://github.com/fmassa/object-detection.torch
|
209 |
-
# Ported to PyTorch by Max deGroot (02/01/2017)
|
210 |
-
def nms(boxes, scores, overlap=0.5, top_k=200):
|
211 |
-
"""Apply non-maximum suppression at test time to avoid detecting too many
|
212 |
-
overlapping bounding boxes for a given object.
|
213 |
-
Args:
|
214 |
-
boxes: (tensor) The location preds for the img, Shape: [num_priors,4].
|
215 |
-
scores: (tensor) The class predscores for the img, Shape:[num_priors].
|
216 |
-
overlap: (float) The overlap thresh for suppressing unnecessary boxes.
|
217 |
-
top_k: (int) The Maximum number of box preds to consider.
|
218 |
-
Return:
|
219 |
-
The indices of the kept boxes with respect to num_priors.
|
220 |
-
"""
|
221 |
-
|
222 |
-
keep = torch.Tensor(scores.size(0)).fill_(0).long()
|
223 |
-
if boxes.numel() == 0:
|
224 |
-
return keep
|
225 |
-
x1 = boxes[:, 0]
|
226 |
-
y1 = boxes[:, 1]
|
227 |
-
x2 = boxes[:, 2]
|
228 |
-
y2 = boxes[:, 3]
|
229 |
-
area = torch.mul(x2 - x1, y2 - y1)
|
230 |
-
v, idx = scores.sort(0) # sort in ascending order
|
231 |
-
# I = I[v >= 0.01]
|
232 |
-
idx = idx[-top_k:] # indices of the top-k largest vals
|
233 |
-
xx1 = boxes.new()
|
234 |
-
yy1 = boxes.new()
|
235 |
-
xx2 = boxes.new()
|
236 |
-
yy2 = boxes.new()
|
237 |
-
w = boxes.new()
|
238 |
-
h = boxes.new()
|
239 |
-
|
240 |
-
# keep = torch.Tensor()
|
241 |
-
count = 0
|
242 |
-
while idx.numel() > 0:
|
243 |
-
i = idx[-1] # index of current largest val
|
244 |
-
# keep.append(i)
|
245 |
-
keep[count] = i
|
246 |
-
count += 1
|
247 |
-
if idx.size(0) == 1:
|
248 |
-
break
|
249 |
-
idx = idx[:-1] # remove kept element from view
|
250 |
-
# load bboxes of next highest vals
|
251 |
-
torch.index_select(x1, 0, idx, out=xx1)
|
252 |
-
torch.index_select(y1, 0, idx, out=yy1)
|
253 |
-
torch.index_select(x2, 0, idx, out=xx2)
|
254 |
-
torch.index_select(y2, 0, idx, out=yy2)
|
255 |
-
# store element-wise max with next highest score
|
256 |
-
xx1 = torch.clamp(xx1, min=x1[i])
|
257 |
-
yy1 = torch.clamp(yy1, min=y1[i])
|
258 |
-
xx2 = torch.clamp(xx2, max=x2[i])
|
259 |
-
yy2 = torch.clamp(yy2, max=y2[i])
|
260 |
-
w.resize_as_(xx2)
|
261 |
-
h.resize_as_(yy2)
|
262 |
-
w = xx2 - xx1
|
263 |
-
h = yy2 - yy1
|
264 |
-
# check sizes of xx1 and xx2.. after each iteration
|
265 |
-
w = torch.clamp(w, min=0.0)
|
266 |
-
h = torch.clamp(h, min=0.0)
|
267 |
-
inter = w*h
|
268 |
-
# IoU = i / (area(a) + area(b) - i)
|
269 |
-
rem_areas = torch.index_select(area, 0, idx) # load remaining areas)
|
270 |
-
union = (rem_areas - inter) + area[i]
|
271 |
-
IoU = inter/union # store result in iou
|
272 |
-
# keep only elements with an IoU <= overlap
|
273 |
-
idx = idx[IoU.le(overlap)]
|
274 |
-
return keep, count
|
275 |
-
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/build.py
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from os.path import join as pjoin
|
3 |
-
import numpy as np
|
4 |
-
from distutils.core import setup
|
5 |
-
from distutils.extension import Extension
|
6 |
-
from Cython.Distutils import build_ext
|
7 |
-
|
8 |
-
|
9 |
-
def find_in_path(name, path):
|
10 |
-
"Find a file in a search path"
|
11 |
-
# adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/
|
12 |
-
for dir in path.split(os.pathsep):
|
13 |
-
binpath = pjoin(dir, name)
|
14 |
-
if os.path.exists(binpath):
|
15 |
-
return os.path.abspath(binpath)
|
16 |
-
return None
|
17 |
-
|
18 |
-
|
19 |
-
def locate_cuda():
|
20 |
-
"""Locate the CUDA environment on the system
|
21 |
-
|
22 |
-
Returns a dict with keys 'home', 'nvcc', 'include', and 'lib64'
|
23 |
-
and values giving the absolute path to each directory.
|
24 |
-
|
25 |
-
Starts by looking for the CUDAHOME env variable. If not found, everything
|
26 |
-
is based on finding 'nvcc' in the PATH.
|
27 |
-
"""
|
28 |
-
|
29 |
-
# first check if the CUDAHOME env variable is in use
|
30 |
-
if 'CUDAHOME' in os.environ:
|
31 |
-
home = os.environ['CUDAHOME']
|
32 |
-
nvcc = pjoin(home, 'bin', 'nvcc')
|
33 |
-
else:
|
34 |
-
# otherwise, search the PATH for NVCC
|
35 |
-
default_path = pjoin(os.sep, 'usr', 'local', 'cuda', 'bin')
|
36 |
-
nvcc = find_in_path('nvcc', os.environ['PATH'] + os.pathsep + default_path)
|
37 |
-
if nvcc is None:
|
38 |
-
raise EnvironmentError('The nvcc binary could not be '
|
39 |
-
'located in your $PATH. Either add it to your path, or set $CUDAHOME')
|
40 |
-
home = os.path.dirname(os.path.dirname(nvcc))
|
41 |
-
|
42 |
-
cudaconfig = {'home': home, 'nvcc': nvcc,
|
43 |
-
'include': pjoin(home, 'include'),
|
44 |
-
'lib64': pjoin(home, 'lib64')}
|
45 |
-
for k, v in cudaconfig.items():
|
46 |
-
if not os.path.exists(v):
|
47 |
-
raise EnvironmentError('The CUDA %s path could not be located in %s' % (k, v))
|
48 |
-
|
49 |
-
return cudaconfig
|
50 |
-
|
51 |
-
|
52 |
-
CUDA = locate_cuda()
|
53 |
-
|
54 |
-
# Obtain the numpy include directory. This logic works across numpy versions.
|
55 |
-
try:
|
56 |
-
numpy_include = np.get_include()
|
57 |
-
except AttributeError:
|
58 |
-
numpy_include = np.get_numpy_include()
|
59 |
-
|
60 |
-
|
61 |
-
def customize_compiler_for_nvcc(self):
|
62 |
-
"""inject deep into distutils to customize how the dispatch
|
63 |
-
to gcc/nvcc works.
|
64 |
-
|
65 |
-
If you subclass UnixCCompiler, it's not trivial to get your subclass
|
66 |
-
injected in, and still have the right customizations (i.e.
|
67 |
-
distutils.sysconfig.customize_compiler) run on it. So instead of going
|
68 |
-
the OO route, I have this. Note, it's kindof like a wierd functional
|
69 |
-
subclassing going on."""
|
70 |
-
|
71 |
-
# tell the compiler it can processes .cu
|
72 |
-
self.src_extensions.append('.cu')
|
73 |
-
|
74 |
-
# save references to the default compiler_so and _comple methods
|
75 |
-
default_compiler_so = self.compiler_so
|
76 |
-
super = self._compile
|
77 |
-
|
78 |
-
# now redefine the _compile method. This gets executed for each
|
79 |
-
# object but distutils doesn't have the ability to change compilers
|
80 |
-
# based on source extension: we add it.
|
81 |
-
def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
|
82 |
-
print(extra_postargs)
|
83 |
-
if os.path.splitext(src)[1] == '.cu':
|
84 |
-
# use the cuda for .cu files
|
85 |
-
self.set_executable('compiler_so', CUDA['nvcc'])
|
86 |
-
# use only a subset of the extra_postargs, which are 1-1 translated
|
87 |
-
# from the extra_compile_args in the Extension class
|
88 |
-
postargs = extra_postargs['nvcc']
|
89 |
-
else:
|
90 |
-
postargs = extra_postargs['gcc']
|
91 |
-
|
92 |
-
super(obj, src, ext, cc_args, postargs, pp_opts)
|
93 |
-
# reset the default compiler_so, which we might have changed for cuda
|
94 |
-
self.compiler_so = default_compiler_so
|
95 |
-
|
96 |
-
# inject our redefined _compile method into the class
|
97 |
-
self._compile = _compile
|
98 |
-
|
99 |
-
|
100 |
-
# run the customize_compiler
|
101 |
-
class custom_build_ext(build_ext):
|
102 |
-
def build_extensions(self):
|
103 |
-
customize_compiler_for_nvcc(self.compiler)
|
104 |
-
build_ext.build_extensions(self)
|
105 |
-
|
106 |
-
|
107 |
-
ext_modules = [
|
108 |
-
Extension(
|
109 |
-
"nms.cpu_nms",
|
110 |
-
["nms/cpu_nms.pyx"],
|
111 |
-
extra_compile_args={'gcc': ["-Wno-cpp", "-Wno-unused-function"]},
|
112 |
-
include_dirs=[numpy_include]
|
113 |
-
),
|
114 |
-
Extension('nms.gpu_nms',
|
115 |
-
['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],
|
116 |
-
library_dirs=[CUDA['lib64']],
|
117 |
-
libraries=['cudart'],
|
118 |
-
language='c++',
|
119 |
-
runtime_library_dirs=[CUDA['lib64']],
|
120 |
-
# this syntax is specific to this build system
|
121 |
-
# we're only going to use certain compiler args with nvcc and not with gcc
|
122 |
-
# the implementation of this trick is in customize_compiler() below
|
123 |
-
extra_compile_args={'gcc': ["-Wno-unused-function"],
|
124 |
-
'nvcc': ['-arch=sm_52',
|
125 |
-
'--ptxas-options=-v',
|
126 |
-
'-c',
|
127 |
-
'--compiler-options',
|
128 |
-
"'-fPIC'"]},
|
129 |
-
include_dirs=[numpy_include, CUDA['include']]
|
130 |
-
),
|
131 |
-
]
|
132 |
-
|
133 |
-
setup(
|
134 |
-
name='mot_utils',
|
135 |
-
ext_modules=ext_modules,
|
136 |
-
# inject our custom trigger
|
137 |
-
cmdclass={'build_ext': custom_build_ext},
|
138 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/cpu_nms.o
DELETED
Binary file (961 kB)
|
|
face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/gpu_nms.o
DELETED
Binary file (478 kB)
|
|
face_recognition1/face_detect/utils/build/temp.linux-x86_64-3.6/nms/nms_kernel.o
DELETED
Binary file (41.2 kB)
|
|
face_recognition1/face_detect/utils/nms/cpu_nms.c
DELETED
The diff for this file is too large to render.
See raw diff
|
|
face_recognition1/face_detect/utils/nms/cpu_nms.cpython-36m-x86_64-linux-gnu.so
DELETED
Binary file (399 kB)
|
|
face_recognition1/face_detect/utils/nms/cpu_nms.pyx
DELETED
@@ -1,156 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
cimport numpy as np
|
3 |
-
|
4 |
-
cdef inline np.float32_t max(np.float32_t a, np.float32_t b):
|
5 |
-
return a if a >= b else b
|
6 |
-
|
7 |
-
cdef inline np.float32_t min(np.float32_t a, np.float32_t b):
|
8 |
-
return a if a <= b else b
|
9 |
-
|
10 |
-
def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh):
|
11 |
-
cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0]
|
12 |
-
cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1]
|
13 |
-
cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2]
|
14 |
-
cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3]
|
15 |
-
cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4]
|
16 |
-
|
17 |
-
cdef np.ndarray[np.float32_t, ndim=1] areas = (x2 - x1 + 1) * (y2 - y1 + 1)
|
18 |
-
cdef np.ndarray[np.int_t, ndim=1] order = scores.argsort()[::-1]
|
19 |
-
|
20 |
-
cdef int ndets = dets.shape[0]
|
21 |
-
cdef np.ndarray[np.int_t, ndim=1] suppressed = \
|
22 |
-
np.zeros((ndets), dtype=np.int)
|
23 |
-
|
24 |
-
# nominal indices
|
25 |
-
cdef int _i, _j
|
26 |
-
# sorted indices
|
27 |
-
cdef int i, j
|
28 |
-
# temp variables for box i's (the box currently under consideration)
|
29 |
-
cdef np.float32_t ix1, iy1, ix2, iy2, iarea
|
30 |
-
# variables for computing overlap with box j (lower scoring box)
|
31 |
-
cdef np.float32_t xx1, yy1, xx2, yy2
|
32 |
-
cdef np.float32_t w, h
|
33 |
-
cdef np.float32_t inter, ovr
|
34 |
-
|
35 |
-
keep = []
|
36 |
-
for _i in range(ndets):
|
37 |
-
i = order[_i]
|
38 |
-
if suppressed[i] == 1:
|
39 |
-
continue
|
40 |
-
keep.append(i)
|
41 |
-
ix1 = x1[i]
|
42 |
-
iy1 = y1[i]
|
43 |
-
ix2 = x2[i]
|
44 |
-
iy2 = y2[i]
|
45 |
-
iarea = areas[i]
|
46 |
-
for _j in range(_i + 1, ndets):
|
47 |
-
j = order[_j]
|
48 |
-
if suppressed[j] == 1:
|
49 |
-
continue
|
50 |
-
xx1 = max(ix1, x1[j])
|
51 |
-
yy1 = max(iy1, y1[j])
|
52 |
-
xx2 = min(ix2, x2[j])
|
53 |
-
yy2 = min(iy2, y2[j])
|
54 |
-
w = max(0.0, xx2 - xx1 + 1)
|
55 |
-
h = max(0.0, yy2 - yy1 + 1)
|
56 |
-
inter = w * h
|
57 |
-
ovr = inter / (iarea + areas[j] - inter)
|
58 |
-
if ovr >= thresh:
|
59 |
-
suppressed[j] = 1
|
60 |
-
|
61 |
-
return keep
|
62 |
-
|
63 |
-
def cpu_soft_nms(np.ndarray[float, ndim=2] boxes, float sigma=0.5, float Nt=0.3, float threshold=0.001, unsigned int method=0):
|
64 |
-
cdef unsigned int N = boxes.shape[0]
|
65 |
-
cdef float iw, ih, box_area
|
66 |
-
cdef float ua
|
67 |
-
cdef int pos = 0
|
68 |
-
cdef float maxscore = 0
|
69 |
-
cdef int maxpos = 0
|
70 |
-
cdef float x1,x2,y1,y2,tx1,tx2,ty1,ty2,ts,area,weight,ov
|
71 |
-
|
72 |
-
for i in range(N):
|
73 |
-
maxscore = boxes[i, 4]
|
74 |
-
maxpos = i
|
75 |
-
|
76 |
-
tx1 = boxes[i,0]
|
77 |
-
ty1 = boxes[i,1]
|
78 |
-
tx2 = boxes[i,2]
|
79 |
-
ty2 = boxes[i,3]
|
80 |
-
ts = boxes[i,4]
|
81 |
-
|
82 |
-
pos = i + 1
|
83 |
-
# get max box
|
84 |
-
while pos < N:
|
85 |
-
if maxscore < boxes[pos, 4]:
|
86 |
-
maxscore = boxes[pos, 4]
|
87 |
-
maxpos = pos
|
88 |
-
pos = pos + 1
|
89 |
-
|
90 |
-
# add max box as a detection
|
91 |
-
boxes[i,0] = boxes[maxpos,0]
|
92 |
-
boxes[i,1] = boxes[maxpos,1]
|
93 |
-
boxes[i,2] = boxes[maxpos,2]
|
94 |
-
boxes[i,3] = boxes[maxpos,3]
|
95 |
-
boxes[i,4] = boxes[maxpos,4]
|
96 |
-
|
97 |
-
# swap ith box with position of max box
|
98 |
-
boxes[maxpos,0] = tx1
|
99 |
-
boxes[maxpos,1] = ty1
|
100 |
-
boxes[maxpos,2] = tx2
|
101 |
-
boxes[maxpos,3] = ty2
|
102 |
-
boxes[maxpos,4] = ts
|
103 |
-
|
104 |
-
tx1 = boxes[i,0]
|
105 |
-
ty1 = boxes[i,1]
|
106 |
-
tx2 = boxes[i,2]
|
107 |
-
ty2 = boxes[i,3]
|
108 |
-
ts = boxes[i,4]
|
109 |
-
|
110 |
-
pos = i + 1
|
111 |
-
# NMS iterations, note that N changes if detection boxes fall below threshold
|
112 |
-
while pos < N:
|
113 |
-
x1 = boxes[pos, 0]
|
114 |
-
y1 = boxes[pos, 1]
|
115 |
-
x2 = boxes[pos, 2]
|
116 |
-
y2 = boxes[pos, 3]
|
117 |
-
s = boxes[pos, 4]
|
118 |
-
|
119 |
-
area = (x2 - x1 + 1) * (y2 - y1 + 1)
|
120 |
-
iw = (min(tx2, x2) - max(tx1, x1) + 1)
|
121 |
-
if iw > 0:
|
122 |
-
ih = (min(ty2, y2) - max(ty1, y1) + 1)
|
123 |
-
if ih > 0:
|
124 |
-
ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih)
|
125 |
-
ov = iw * ih / ua #iou between max box and detection box
|
126 |
-
|
127 |
-
if method == 1: # linear
|
128 |
-
if ov > Nt:
|
129 |
-
weight = 1 - ov
|
130 |
-
else:
|
131 |
-
weight = 1
|
132 |
-
elif method == 2: # gaussian
|
133 |
-
weight = np.exp(-(ov * ov)/sigma)
|
134 |
-
else: # original NMS
|
135 |
-
if ov > Nt:
|
136 |
-
weight = 0
|
137 |
-
else:
|
138 |
-
weight = 1
|
139 |
-
|
140 |
-
boxes[pos, 4] = weight*boxes[pos, 4]
|
141 |
-
|
142 |
-
# if box score falls below threshold, discard the box by swapping with last box
|
143 |
-
# update N
|
144 |
-
if boxes[pos, 4] < threshold:
|
145 |
-
boxes[pos,0] = boxes[N-1, 0]
|
146 |
-
boxes[pos,1] = boxes[N-1, 1]
|
147 |
-
boxes[pos,2] = boxes[N-1, 2]
|
148 |
-
boxes[pos,3] = boxes[N-1, 3]
|
149 |
-
boxes[pos,4] = boxes[N-1, 4]
|
150 |
-
N = N - 1
|
151 |
-
pos = pos - 1
|
152 |
-
|
153 |
-
pos = pos + 1
|
154 |
-
|
155 |
-
keep = [i for i in range(N)]
|
156 |
-
return keep
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/nms/gpu_nms.cpp
DELETED
The diff for this file is too large to render.
See raw diff
|
|
face_recognition1/face_detect/utils/nms/gpu_nms.cpython-36m-x86_64-linux-gnu.so
DELETED
Binary file (255 kB)
|
|
face_recognition1/face_detect/utils/nms/gpu_nms.hpp
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num,
|
2 |
-
int boxes_dim, float nms_overlap_thresh, int device_id);
|
|
|
|
|
|
face_recognition1/face_detect/utils/nms/gpu_nms.pyx
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
cimport numpy as np
|
3 |
-
|
4 |
-
assert sizeof(int) == sizeof(np.int32_t)
|
5 |
-
|
6 |
-
cdef extern from "gpu_nms.hpp":
|
7 |
-
void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int)
|
8 |
-
|
9 |
-
def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh,
|
10 |
-
np.int32_t device_id=0):
|
11 |
-
cdef int boxes_num = dets.shape[0]
|
12 |
-
cdef int boxes_dim = dets.shape[1]
|
13 |
-
cdef int num_out
|
14 |
-
cdef np.ndarray[np.int32_t, ndim=1] \
|
15 |
-
keep = np.zeros(boxes_num, dtype=np.int32)
|
16 |
-
cdef np.ndarray[np.float32_t, ndim=1] \
|
17 |
-
scores = dets[:, 4]
|
18 |
-
cdef np.ndarray[np.int_t, ndim=1] \
|
19 |
-
order = scores.argsort()[::-1]
|
20 |
-
cdef np.ndarray[np.float32_t, ndim=2] \
|
21 |
-
sorted_dets = dets[order, :]
|
22 |
-
_nms(&keep[0], &num_out, &sorted_dets[0, 0], boxes_num, boxes_dim, thresh, device_id)
|
23 |
-
keep = keep[:num_out]
|
24 |
-
return list(order[keep])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/nms/nms_kernel.cu
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
// ------------------------------------------------------------------
|
2 |
-
// Faster R-CNN
|
3 |
-
// Copyright (c) 2015 Microsoft
|
4 |
-
// Licensed under The MIT License [see fast-rcnn/LICENSE for details]
|
5 |
-
// Written by Shaoqing Ren
|
6 |
-
// ------------------------------------------------------------------
|
7 |
-
|
8 |
-
#include "gpu_nms.hpp"
|
9 |
-
#include <vector>
|
10 |
-
#include <iostream>
|
11 |
-
|
12 |
-
#define CUDA_CHECK(condition) \
|
13 |
-
/* Code block avoids redefinition of cudaError_t error */ \
|
14 |
-
do { \
|
15 |
-
cudaError_t error = condition; \
|
16 |
-
if (error != cudaSuccess) { \
|
17 |
-
std::cout << cudaGetErrorString(error) << std::endl; \
|
18 |
-
} \
|
19 |
-
} while (0)
|
20 |
-
|
21 |
-
#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0))
|
22 |
-
int const threadsPerBlock = sizeof(unsigned long long) * 8;
|
23 |
-
|
24 |
-
__device__ inline float devIoU(float const * const a, float const * const b) {
|
25 |
-
float left = max(a[0], b[0]), right = min(a[2], b[2]);
|
26 |
-
float top = max(a[1], b[1]), bottom = min(a[3], b[3]);
|
27 |
-
float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f);
|
28 |
-
float interS = width * height;
|
29 |
-
float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1);
|
30 |
-
float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1);
|
31 |
-
return interS / (Sa + Sb - interS);
|
32 |
-
}
|
33 |
-
|
34 |
-
__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh,
|
35 |
-
const float *dev_boxes, unsigned long long *dev_mask) {
|
36 |
-
const int row_start = blockIdx.y;
|
37 |
-
const int col_start = blockIdx.x;
|
38 |
-
|
39 |
-
// if (row_start > col_start) return;
|
40 |
-
|
41 |
-
const int row_size =
|
42 |
-
min(n_boxes - row_start * threadsPerBlock, threadsPerBlock);
|
43 |
-
const int col_size =
|
44 |
-
min(n_boxes - col_start * threadsPerBlock, threadsPerBlock);
|
45 |
-
|
46 |
-
__shared__ float block_boxes[threadsPerBlock * 5];
|
47 |
-
if (threadIdx.x < col_size) {
|
48 |
-
block_boxes[threadIdx.x * 5 + 0] =
|
49 |
-
dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0];
|
50 |
-
block_boxes[threadIdx.x * 5 + 1] =
|
51 |
-
dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1];
|
52 |
-
block_boxes[threadIdx.x * 5 + 2] =
|
53 |
-
dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2];
|
54 |
-
block_boxes[threadIdx.x * 5 + 3] =
|
55 |
-
dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3];
|
56 |
-
block_boxes[threadIdx.x * 5 + 4] =
|
57 |
-
dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4];
|
58 |
-
}
|
59 |
-
__syncthreads();
|
60 |
-
|
61 |
-
if (threadIdx.x < row_size) {
|
62 |
-
const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x;
|
63 |
-
const float *cur_box = dev_boxes + cur_box_idx * 5;
|
64 |
-
int i = 0;
|
65 |
-
unsigned long long t = 0;
|
66 |
-
int start = 0;
|
67 |
-
if (row_start == col_start) {
|
68 |
-
start = threadIdx.x + 1;
|
69 |
-
}
|
70 |
-
for (i = start; i < col_size; i++) {
|
71 |
-
if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) {
|
72 |
-
t |= 1ULL << i;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
const int col_blocks = DIVUP(n_boxes, threadsPerBlock);
|
76 |
-
dev_mask[cur_box_idx * col_blocks + col_start] = t;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
void _set_device(int device_id) {
|
81 |
-
int current_device;
|
82 |
-
CUDA_CHECK(cudaGetDevice(¤t_device));
|
83 |
-
if (current_device == device_id) {
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
// The call to cudaSetDevice must come before any calls to Get, which
|
87 |
-
// may perform initialization using the GPU.
|
88 |
-
CUDA_CHECK(cudaSetDevice(device_id));
|
89 |
-
}
|
90 |
-
|
91 |
-
void _nms(int* keep_out, int* num_out, const float* boxes_host, int boxes_num,
|
92 |
-
int boxes_dim, float nms_overlap_thresh, int device_id) {
|
93 |
-
_set_device(device_id);
|
94 |
-
|
95 |
-
float* boxes_dev = NULL;
|
96 |
-
unsigned long long* mask_dev = NULL;
|
97 |
-
|
98 |
-
const int col_blocks = DIVUP(boxes_num, threadsPerBlock);
|
99 |
-
|
100 |
-
CUDA_CHECK(cudaMalloc(&boxes_dev,
|
101 |
-
boxes_num * boxes_dim * sizeof(float)));
|
102 |
-
CUDA_CHECK(cudaMemcpy(boxes_dev,
|
103 |
-
boxes_host,
|
104 |
-
boxes_num * boxes_dim * sizeof(float),
|
105 |
-
cudaMemcpyHostToDevice));
|
106 |
-
|
107 |
-
CUDA_CHECK(cudaMalloc(&mask_dev,
|
108 |
-
boxes_num * col_blocks * sizeof(unsigned long long)));
|
109 |
-
|
110 |
-
dim3 blocks(DIVUP(boxes_num, threadsPerBlock),
|
111 |
-
DIVUP(boxes_num, threadsPerBlock));
|
112 |
-
dim3 threads(threadsPerBlock);
|
113 |
-
nms_kernel<<<blocks, threads>>>(boxes_num,
|
114 |
-
nms_overlap_thresh,
|
115 |
-
boxes_dev,
|
116 |
-
mask_dev);
|
117 |
-
|
118 |
-
std::vector<unsigned long long> mask_host(boxes_num * col_blocks);
|
119 |
-
CUDA_CHECK(cudaMemcpy(&mask_host[0],
|
120 |
-
mask_dev,
|
121 |
-
sizeof(unsigned long long) * boxes_num * col_blocks,
|
122 |
-
cudaMemcpyDeviceToHost));
|
123 |
-
|
124 |
-
std::vector<unsigned long long> remv(col_blocks);
|
125 |
-
memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks);
|
126 |
-
|
127 |
-
int num_to_keep = 0;
|
128 |
-
for (int i = 0; i < boxes_num; i++) {
|
129 |
-
int nblock = i / threadsPerBlock;
|
130 |
-
int inblock = i % threadsPerBlock;
|
131 |
-
|
132 |
-
if (!(remv[nblock] & (1ULL << inblock))) {
|
133 |
-
keep_out[num_to_keep++] = i;
|
134 |
-
unsigned long long *p = &mask_host[0] + i * col_blocks;
|
135 |
-
for (int j = nblock; j < col_blocks; j++) {
|
136 |
-
remv[j] |= p[j];
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
*num_out = num_to_keep;
|
141 |
-
|
142 |
-
CUDA_CHECK(cudaFree(boxes_dev));
|
143 |
-
CUDA_CHECK(cudaFree(mask_dev));
|
144 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/nms/py_cpu_nms.py
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
|
3 |
-
|
4 |
-
def py_cpu_nms(dets, thresh):
|
5 |
-
"""Pure Python NMS baseline."""
|
6 |
-
x1 = dets[:, 0]
|
7 |
-
y1 = dets[:, 1]
|
8 |
-
x2 = dets[:, 2]
|
9 |
-
y2 = dets[:, 3]
|
10 |
-
scores = dets[:, 4]
|
11 |
-
|
12 |
-
areas = (x2 - x1 + 1) * (y2 - y1 + 1)
|
13 |
-
order = scores.argsort()[::-1]
|
14 |
-
|
15 |
-
keep = []
|
16 |
-
while order.size > 0:
|
17 |
-
i = order[0]
|
18 |
-
keep.append(i)
|
19 |
-
xx1 = np.maximum(x1[i], x1[order[1:]])
|
20 |
-
yy1 = np.maximum(y1[i], y1[order[1:]])
|
21 |
-
xx2 = np.minimum(x2[i], x2[order[1:]])
|
22 |
-
yy2 = np.minimum(y2[i], y2[order[1:]])
|
23 |
-
|
24 |
-
w = np.maximum(0.0, xx2 - xx1 + 1)
|
25 |
-
h = np.maximum(0.0, yy2 - yy1 + 1)
|
26 |
-
inter = w * h
|
27 |
-
ovr = inter / (areas[i] + areas[order[1:]] - inter)
|
28 |
-
|
29 |
-
inds = np.where(ovr <= thresh)[0]
|
30 |
-
order = order[inds + 1]
|
31 |
-
|
32 |
-
return keep
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/nms_wrapper.py
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import sys
|
3 |
-
sys.path.append(os.path.dirname(__file__))
|
4 |
-
|
5 |
-
# from nms.cpu_nms import cpu_nms, cpu_soft_nms
|
6 |
-
# from utils.nms.gpu_nms import gpu_nms
|
7 |
-
from nms.py_cpu_nms import py_cpu_nms
|
8 |
-
|
9 |
-
|
10 |
-
# def nms(dets, thresh, force_cpu=False):
|
11 |
-
# """Dispatch to either CPU or GPU NMS implementations."""
|
12 |
-
#
|
13 |
-
# if dets.shape[0] == 0:
|
14 |
-
# return []
|
15 |
-
# if cfg.USE_GPU_NMS and not force_cpu:
|
16 |
-
# return gpu_nms(dets, thresh, device_id=cfg.GPU_ID)
|
17 |
-
# else:
|
18 |
-
# return cpu_nms(dets, thresh)
|
19 |
-
|
20 |
-
|
21 |
-
def nms(dets, thresh, force_cpu=False):
|
22 |
-
"""Dispatch to either CPU or GPU NMS implementations."""
|
23 |
-
|
24 |
-
if dets.shape[0] == 0:
|
25 |
-
return []
|
26 |
-
# if force_cpu:
|
27 |
-
#return cpu_soft_nms(dets, thresh, method = 0)
|
28 |
-
return py_cpu_nms(dets, thresh)
|
29 |
-
# return gpu_nms(dets, thresh)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_detect/utils/timer.py
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
import time
|
2 |
-
|
3 |
-
|
4 |
-
class Timer(object):
|
5 |
-
"""A simple timer."""
|
6 |
-
def __init__(self):
|
7 |
-
self.total_time = 0.
|
8 |
-
self.calls = 0
|
9 |
-
self.start_time = 0.
|
10 |
-
self.diff = 0.
|
11 |
-
self.average_time = 0.
|
12 |
-
|
13 |
-
def tic(self):
|
14 |
-
# using time.time instead of time.clock because time time.clock
|
15 |
-
# does not normalize for multithreading
|
16 |
-
self.start_time = time.time()
|
17 |
-
|
18 |
-
def toc(self, average=True):
|
19 |
-
self.diff = time.time() - self.start_time
|
20 |
-
self.total_time += self.diff
|
21 |
-
self.calls += 1
|
22 |
-
self.average_time = self.total_time / self.calls
|
23 |
-
if average:
|
24 |
-
return self.average_time
|
25 |
-
else:
|
26 |
-
return self.diff
|
27 |
-
|
28 |
-
def clear(self):
|
29 |
-
self.total_time = 0.
|
30 |
-
self.calls = 0
|
31 |
-
self.start_time = 0.
|
32 |
-
self.diff = 0.
|
33 |
-
self.average_time = 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/__init__.py
DELETED
File without changes
|
face_recognition1/face_feature/checkpoints/feat_net.ckpt
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:cbe719b05e516bfc7a3692f4edc448b4eac368e536676a2278cb4facafb8b3d0
|
3 |
-
size 299884972
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/__init__.py
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: __init__.py.py
|
6 |
-
@desc:
|
7 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/agedb.py
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: agedb.py.py
|
6 |
-
@desc: AgeDB-30 test data loader, agedb test protocol is the same with lfw
|
7 |
-
'''
|
8 |
-
|
9 |
-
import os
|
10 |
-
import numpy as np
|
11 |
-
import cv2
|
12 |
-
import torch.utils.data as data
|
13 |
-
|
14 |
-
import torch
|
15 |
-
import torchvision.transforms as transforms
|
16 |
-
|
17 |
-
|
18 |
-
def img_loader(path):
|
19 |
-
try:
|
20 |
-
img = cv2.imread(path)
|
21 |
-
if len(img.shape) == 2:
|
22 |
-
img = np.stack([img] * 3, 2)
|
23 |
-
return img
|
24 |
-
except IOError:
|
25 |
-
print('Cannot load image ' + path)
|
26 |
-
return None
|
27 |
-
|
28 |
-
|
29 |
-
class AgeDB30(data.Dataset):
|
30 |
-
def __init__(self, root, file_list, transform=None, loader=img_loader):
|
31 |
-
super().__init__()
|
32 |
-
self.root = root
|
33 |
-
self.file_list = file_list
|
34 |
-
self.transform = transform
|
35 |
-
self.loader = loader
|
36 |
-
self.nameLs = []
|
37 |
-
self.nameRs = []
|
38 |
-
self.folds = []
|
39 |
-
self.flags = []
|
40 |
-
|
41 |
-
with open(file_list) as f:
|
42 |
-
pairs = f.read().splitlines()
|
43 |
-
for i, p in enumerate(pairs):
|
44 |
-
p = p.split(' ')
|
45 |
-
nameL = p[0]
|
46 |
-
nameR = p[1]
|
47 |
-
fold = i // 600
|
48 |
-
flag = int(p[2])
|
49 |
-
|
50 |
-
self.nameLs.append(nameL)
|
51 |
-
self.nameRs.append(nameR)
|
52 |
-
self.folds.append(fold)
|
53 |
-
self.flags.append(flag)
|
54 |
-
|
55 |
-
def __getitem__(self, index):
|
56 |
-
|
57 |
-
img_l = self.loader(os.path.join(self.root, self.nameLs[index]))
|
58 |
-
img_r = self.loader(os.path.join(self.root, self.nameRs[index]))
|
59 |
-
imglist = [img_l, cv2.flip(img_l, 1), img_r, cv2.flip(img_r, 1)]
|
60 |
-
|
61 |
-
if self.transform is not None:
|
62 |
-
for _, i in enumerate(imglist):
|
63 |
-
imglist[i] = self.transform(imglist[i])
|
64 |
-
|
65 |
-
imgs = imglist
|
66 |
-
return imgs
|
67 |
-
else:
|
68 |
-
imgs = [torch.from_numpy(i) for i in imglist]
|
69 |
-
return imgs
|
70 |
-
|
71 |
-
def __len__(self):
|
72 |
-
return len(self.nameLs)
|
73 |
-
|
74 |
-
|
75 |
-
if __name__ == '__main__':
|
76 |
-
root = '/media/sda/AgeDB-30/agedb30_align_112'
|
77 |
-
file_list = '/media/sda/AgeDB-30/agedb_30_pair.txt'
|
78 |
-
|
79 |
-
transform = transforms.Compose([
|
80 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
81 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
82 |
-
])
|
83 |
-
|
84 |
-
dataset = AgeDB30(root, file_list, transform=transform)
|
85 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=False, num_workers=2, drop_last=False)
|
86 |
-
for data in trainloader:
|
87 |
-
for d in data:
|
88 |
-
print(d[0].shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/casia_webface.py
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: casia_webface.py
|
6 |
-
@desc: CASIA-WebFace dataloader loader
|
7 |
-
'''
|
8 |
-
|
9 |
-
import os
|
10 |
-
import torch
|
11 |
-
import torch.utils.data as data
|
12 |
-
import torchvision.transforms as transforms
|
13 |
-
import numpy as np
|
14 |
-
import cv2
|
15 |
-
|
16 |
-
|
17 |
-
def img_loader(path):
|
18 |
-
try:
|
19 |
-
img = cv2.imread(path)
|
20 |
-
if len(img.shape) == 2:
|
21 |
-
img = np.stack([img] * 3, 2)
|
22 |
-
return img
|
23 |
-
except IOError:
|
24 |
-
print('Cannot load image ' + path)
|
25 |
-
return None
|
26 |
-
|
27 |
-
|
28 |
-
class CASIAWebFace(data.Dataset):
|
29 |
-
def __init__(self, root, file_list, transform=None, loader=img_loader):
|
30 |
-
super().__init__()
|
31 |
-
self.root = root
|
32 |
-
self.transform = transform
|
33 |
-
self.loader = loader
|
34 |
-
|
35 |
-
image_list = []
|
36 |
-
label_list = []
|
37 |
-
with open(file_list) as f:
|
38 |
-
img_label_list = f.read().splitlines()
|
39 |
-
for info in img_label_list:
|
40 |
-
image_path, label_name = info.split(' ')
|
41 |
-
image_list.append(image_path)
|
42 |
-
label_list.append(int(label_name))
|
43 |
-
|
44 |
-
self.image_list = image_list
|
45 |
-
self.label_list = label_list
|
46 |
-
self.class_nums = len(np.unique(self.label_list))
|
47 |
-
print("dataloader size: ", len(self.image_list), '/', self.class_nums)
|
48 |
-
|
49 |
-
def __getitem__(self, index):
|
50 |
-
img_path = self.image_list[index]
|
51 |
-
label = self.label_list[index]
|
52 |
-
|
53 |
-
img = self.loader(os.path.join(self.root, img_path))
|
54 |
-
|
55 |
-
# random flip with ratio of 0.5
|
56 |
-
flip = np.random.choice(2) * 2 - 1
|
57 |
-
if flip == 1:
|
58 |
-
img = cv2.flip(img, 1)
|
59 |
-
|
60 |
-
if self.transform is not None:
|
61 |
-
img = self.transform(img)
|
62 |
-
else:
|
63 |
-
img = torch.from_numpy(img)
|
64 |
-
|
65 |
-
return img, label
|
66 |
-
|
67 |
-
def __len__(self):
|
68 |
-
return len(self.image_list)
|
69 |
-
|
70 |
-
|
71 |
-
class CASIAWebFaceDataset:
|
72 |
-
def __init__(self, root, file_list, loader=img_loader):
|
73 |
-
super().__init__()
|
74 |
-
self.root = root
|
75 |
-
self.loader = loader
|
76 |
-
|
77 |
-
image_list = []
|
78 |
-
label_list = []
|
79 |
-
with open(file_list) as f:
|
80 |
-
img_label_list = f.read().splitlines()
|
81 |
-
for i in range(0, len(img_label_list), 10):
|
82 |
-
info = img_label_list[i]
|
83 |
-
image_path, label_name = info.split(' ')
|
84 |
-
image_list.append(image_path)
|
85 |
-
label_list.append(int(label_name))
|
86 |
-
|
87 |
-
self.image_list = image_list
|
88 |
-
self.label_list = label_list
|
89 |
-
self.class_nums = len(np.unique(self.label_list))
|
90 |
-
print("dataloader size: ", len(self.image_list), '/', self.class_nums)
|
91 |
-
|
92 |
-
def __getitem__(self, index):
|
93 |
-
img_path = self.image_list[index]
|
94 |
-
label = self.label_list[index]
|
95 |
-
|
96 |
-
img = self.loader(os.path.join(self.root, img_path))
|
97 |
-
|
98 |
-
# random flip with ratio of 0.5
|
99 |
-
flip = np.random.choice(2) * 2 - 1
|
100 |
-
if flip == 1:
|
101 |
-
img = cv2.flip(img, 1)
|
102 |
-
|
103 |
-
img = img.astype(np.float32).transpose((2, 1, 0))
|
104 |
-
img = (img - 127.5) / 127.5
|
105 |
-
|
106 |
-
return img, label
|
107 |
-
|
108 |
-
def __len__(self):
|
109 |
-
return len(self.image_list)
|
110 |
-
|
111 |
-
|
112 |
-
if __name__ == '__main__':
|
113 |
-
root = 'D:/data/webface_align_112'
|
114 |
-
file_list = 'D:/data/webface_align_train.list'
|
115 |
-
|
116 |
-
transform = transforms.Compose([
|
117 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
118 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
119 |
-
])
|
120 |
-
dataset = CASIAWebFace(root, file_list, transform=transform)
|
121 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=True, num_workers=2, drop_last=False)
|
122 |
-
print(len(dataset))
|
123 |
-
for data in trainloader:
|
124 |
-
print(data[0].shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/cfp.py
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: cfp.py
|
6 |
-
@desc: the CFP-FP test dataloader loader, it's similar with lfw and adedb, except that it has 700 pairs every fold
|
7 |
-
'''
|
8 |
-
|
9 |
-
|
10 |
-
import os
|
11 |
-
import numpy as np
|
12 |
-
import cv2
|
13 |
-
import torch.utils.data as data
|
14 |
-
import torch
|
15 |
-
import torchvision.transforms as transforms
|
16 |
-
|
17 |
-
|
18 |
-
def img_loader(path):
|
19 |
-
try:
|
20 |
-
img = cv2.imread(path)
|
21 |
-
if len(img.shape) == 2:
|
22 |
-
img = np.stack([img] * 3, 2)
|
23 |
-
return img
|
24 |
-
except IOError:
|
25 |
-
print('Cannot load image ' + path)
|
26 |
-
return None
|
27 |
-
|
28 |
-
|
29 |
-
class CFP_FP(data.Dataset):
|
30 |
-
def __init__(self, root, file_list, transform=None, loader=img_loader):
|
31 |
-
super().__init__()
|
32 |
-
self.root = root
|
33 |
-
self.file_list = file_list
|
34 |
-
self.transform = transform
|
35 |
-
self.loader = loader
|
36 |
-
self.nameLs = []
|
37 |
-
self.nameRs = []
|
38 |
-
self.folds = []
|
39 |
-
self.flags = []
|
40 |
-
|
41 |
-
with open(file_list) as f:
|
42 |
-
pairs = f.read().splitlines()
|
43 |
-
for i, p in enumerate(pairs):
|
44 |
-
p = p.split(' ')
|
45 |
-
nameL = p[0]
|
46 |
-
nameR = p[1]
|
47 |
-
fold = i // 700
|
48 |
-
flag = int(p[2])
|
49 |
-
|
50 |
-
self.nameLs.append(nameL)
|
51 |
-
self.nameRs.append(nameR)
|
52 |
-
self.folds.append(fold)
|
53 |
-
self.flags.append(flag)
|
54 |
-
|
55 |
-
def __getitem__(self, index):
|
56 |
-
|
57 |
-
img_l = self.loader(os.path.join(self.root, self.nameLs[index]))
|
58 |
-
img_r = self.loader(os.path.join(self.root, self.nameRs[index]))
|
59 |
-
imglist = [img_l, cv2.flip(img_l, 1), img_r, cv2.flip(img_r, 1)]
|
60 |
-
|
61 |
-
if self.transform is not None:
|
62 |
-
for _, i in enumerate(imglist):
|
63 |
-
imglist[i] = self.transform(imglist[i])
|
64 |
-
|
65 |
-
imgs = imglist
|
66 |
-
return imgs
|
67 |
-
else:
|
68 |
-
imgs = [torch.from_numpy(i) for i in imglist]
|
69 |
-
return imgs
|
70 |
-
|
71 |
-
def __len__(self):
|
72 |
-
return len(self.nameLs)
|
73 |
-
|
74 |
-
|
75 |
-
if __name__ == '__main__':
|
76 |
-
root = '/media/sda/CFP-FP/CFP_FP_aligned_112'
|
77 |
-
file_list = '/media/sda/CFP-FP/cfp-fp-pair.txt'
|
78 |
-
|
79 |
-
transform = transforms.Compose([
|
80 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
81 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
82 |
-
])
|
83 |
-
|
84 |
-
dataset = CFP_FP(root, file_list, transform=transform)
|
85 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=False, num_workers=2, drop_last=False)
|
86 |
-
for data in trainloader:
|
87 |
-
for d in data:
|
88 |
-
print(d[0].shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/lfw.py
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: lfw.py.py
|
6 |
-
@desc: lfw dataloader loader
|
7 |
-
'''
|
8 |
-
|
9 |
-
import os
|
10 |
-
import numpy as np
|
11 |
-
import cv2
|
12 |
-
import torch
|
13 |
-
import torch.utils.data as data
|
14 |
-
import torchvision.transforms as transforms
|
15 |
-
|
16 |
-
|
17 |
-
def img_loader(path):
|
18 |
-
try:
|
19 |
-
img = cv2.imread(path)
|
20 |
-
if len(img.shape) == 2:
|
21 |
-
img = np.stack([img] * 3, 2)
|
22 |
-
return img
|
23 |
-
except IOError:
|
24 |
-
print('Cannot load image ' + path)
|
25 |
-
return None
|
26 |
-
|
27 |
-
|
28 |
-
class LFW(data.Dataset):
|
29 |
-
def __init__(self, root, file_list, transform=None, loader=img_loader):
|
30 |
-
super().__init__()
|
31 |
-
self.root = root
|
32 |
-
self.file_list = file_list
|
33 |
-
self.transform = transform
|
34 |
-
self.loader = loader
|
35 |
-
self.nameLs = []
|
36 |
-
self.nameRs = []
|
37 |
-
self.folds = []
|
38 |
-
self.flags = []
|
39 |
-
|
40 |
-
with open(file_list) as f:
|
41 |
-
pairs = f.read().splitlines()[1:]
|
42 |
-
for i, p in enumerate(pairs):
|
43 |
-
p = p.split(' ')
|
44 |
-
nameL = p[0]
|
45 |
-
nameR = p[1]
|
46 |
-
fold = i // 600
|
47 |
-
flag = int(p[2])
|
48 |
-
|
49 |
-
self.nameLs.append(nameL)
|
50 |
-
self.nameRs.append(nameR)
|
51 |
-
self.folds.append(fold)
|
52 |
-
self.flags.append(flag)
|
53 |
-
|
54 |
-
def __getitem__(self, index):
|
55 |
-
|
56 |
-
img_l = self.loader(os.path.join(self.root, self.nameLs[index]))
|
57 |
-
img_r = self.loader(os.path.join(self.root, self.nameRs[index]))
|
58 |
-
imglist = [img_l, cv2.flip(img_l, 1), img_r, cv2.flip(img_r, 1)]
|
59 |
-
|
60 |
-
if self.transform is not None:
|
61 |
-
for _, i in enumerate(imglist):
|
62 |
-
imglist[i] = self.transform(imglist[i])
|
63 |
-
|
64 |
-
imgs = imglist
|
65 |
-
return imgs
|
66 |
-
else:
|
67 |
-
imgs = [torch.from_numpy(i) for i in imglist]
|
68 |
-
return imgs
|
69 |
-
|
70 |
-
def __len__(self):
|
71 |
-
return len(self.nameLs)
|
72 |
-
|
73 |
-
|
74 |
-
class LFWDataset:
|
75 |
-
def __init__(self, root, file_list, loader=img_loader):
|
76 |
-
super().__init__()
|
77 |
-
self.root = root
|
78 |
-
self.file_list = file_list
|
79 |
-
self.loader = loader
|
80 |
-
self.nameLs = []
|
81 |
-
self.nameRs = []
|
82 |
-
self.folds = []
|
83 |
-
self.flags = []
|
84 |
-
|
85 |
-
with open(file_list) as f:
|
86 |
-
pairs = f.read().splitlines()[1:]
|
87 |
-
for i, p in enumerate(pairs):
|
88 |
-
p = p.split(' ')
|
89 |
-
nameL = p[0]
|
90 |
-
nameR = p[1]
|
91 |
-
fold = i // 600
|
92 |
-
flag = int(p[2])
|
93 |
-
|
94 |
-
self.nameLs.append(nameL)
|
95 |
-
self.nameRs.append(nameR)
|
96 |
-
self.folds.append(fold)
|
97 |
-
self.flags.append(flag)
|
98 |
-
|
99 |
-
self.idx = 0
|
100 |
-
self.len = len(self.nameLs)
|
101 |
-
|
102 |
-
def __next__(self, index):
|
103 |
-
if self.idx > self.len:
|
104 |
-
raise StopIteration
|
105 |
-
|
106 |
-
img_l = self.loader(os.path.join(self.root, self.nameLs[self.idx]))
|
107 |
-
img_r = self.loader(os.path.join(self.root, self.nameRs[self.idx]))
|
108 |
-
imglist = [img_l, cv2.flip(img_l, 1), img_r, cv2.flip(img_r, 1)]
|
109 |
-
|
110 |
-
outputs = []
|
111 |
-
image_mean = np.array([127.5, 127.5, 127.5])
|
112 |
-
for _, image in enumerate(imglist):
|
113 |
-
img = (image - image_mean) / 127.5
|
114 |
-
img = img.astype(np.float32).transpose((2, 0, 1))
|
115 |
-
img = np.expand_dims(img, axis=0)
|
116 |
-
|
117 |
-
outputs.append(img)
|
118 |
-
|
119 |
-
self.idx += 1
|
120 |
-
return outputs
|
121 |
-
|
122 |
-
def __iter__(self):
|
123 |
-
return self
|
124 |
-
|
125 |
-
|
126 |
-
if __name__ == '__main__':
|
127 |
-
root = 'D:/data/lfw_align_112'
|
128 |
-
file_list = 'D:/data/pairs.txt'
|
129 |
-
|
130 |
-
transform = transforms.Compose([
|
131 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]+
|
132 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
133 |
-
])
|
134 |
-
|
135 |
-
dataset = LFW(root, file_list, transform=transform)
|
136 |
-
#dataloader = LFW(root, file_list)
|
137 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=False, num_workers=2, drop_last=False)
|
138 |
-
print(len(dataset))
|
139 |
-
for data in trainloader:
|
140 |
-
for d in data:
|
141 |
-
print(d[0].shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/lfw_2.py
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: lfw_2.py
|
6 |
-
@desc: lfw dataloader from insightface ,just like agedb and cfp-fp
|
7 |
-
'''
|
8 |
-
|
9 |
-
import os
|
10 |
-
|
11 |
-
import torch
|
12 |
-
import torch.utils.data as data
|
13 |
-
import torchvision.transforms as transforms
|
14 |
-
import numpy as np
|
15 |
-
import cv2
|
16 |
-
|
17 |
-
|
18 |
-
def img_loader(path):
|
19 |
-
try:
|
20 |
-
img = cv2.imread(path)
|
21 |
-
if len(img.shape) == 2:
|
22 |
-
img = np.stack([img] * 3, 2)
|
23 |
-
return img
|
24 |
-
except IOError:
|
25 |
-
print('Cannot load image ' + path)
|
26 |
-
return None
|
27 |
-
|
28 |
-
|
29 |
-
class LFW_2(data.Dataset):
|
30 |
-
def __init__(self, root, file_list, transform=None, loader=img_loader):
|
31 |
-
super().__init__()
|
32 |
-
self.root = root
|
33 |
-
self.file_list = file_list
|
34 |
-
self.transform = transform
|
35 |
-
self.loader = loader
|
36 |
-
self.nameLs = []
|
37 |
-
self.nameRs = []
|
38 |
-
self.folds = []
|
39 |
-
self.flags = []
|
40 |
-
|
41 |
-
with open(file_list) as f:
|
42 |
-
pairs = f.read().splitlines()
|
43 |
-
for i, p in enumerate(pairs):
|
44 |
-
p = p.split(' ')
|
45 |
-
nameL = p[0]
|
46 |
-
nameR = p[1]
|
47 |
-
fold = i // 600
|
48 |
-
flag = int(p[2])
|
49 |
-
|
50 |
-
self.nameLs.append(nameL)
|
51 |
-
self.nameRs.append(nameR)
|
52 |
-
self.folds.append(fold)
|
53 |
-
self.flags.append(flag)
|
54 |
-
|
55 |
-
def __getitem__(self, index):
|
56 |
-
|
57 |
-
img_l = self.loader(os.path.join(self.root, self.nameLs[index]))
|
58 |
-
img_r = self.loader(os.path.join(self.root, self.nameRs[index]))
|
59 |
-
imglist = [img_l, cv2.flip(img_l, 1), img_r, cv2.flip(img_r, 1)]
|
60 |
-
|
61 |
-
if self.transform is not None:
|
62 |
-
for _, i in enumerate(imglist):
|
63 |
-
imglist[i] = self.transform(imglist[i])
|
64 |
-
|
65 |
-
imgs = imglist
|
66 |
-
return imgs
|
67 |
-
else:
|
68 |
-
imgs = [torch.from_numpy(i) for i in imglist]
|
69 |
-
return imgs
|
70 |
-
|
71 |
-
def __len__(self):
|
72 |
-
return len(self.nameLs)
|
73 |
-
|
74 |
-
|
75 |
-
if __name__ == '__main__':
|
76 |
-
root = '/media/sda/insightface_emore/lfw'
|
77 |
-
file_list = '/media/sda/insightface_emore/pair_lfw.txt'
|
78 |
-
|
79 |
-
transform = transforms.Compose([
|
80 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
81 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
82 |
-
])
|
83 |
-
|
84 |
-
dataset = LFW_2(root, file_list, transform=transform)
|
85 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=False, num_workers=2, drop_last=False)
|
86 |
-
for data in trainloader:
|
87 |
-
for d in data:
|
88 |
-
print(d[0].shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/dataloader/megaface.py
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: megaface.py
|
6 |
-
@desc:
|
7 |
-
'''
|
8 |
-
|
9 |
-
import os
|
10 |
-
import numpy as np
|
11 |
-
import cv2
|
12 |
-
import torch
|
13 |
-
import torch.utils.data as data
|
14 |
-
import torchvision.transforms as transforms
|
15 |
-
|
16 |
-
|
17 |
-
def img_loader(path):
|
18 |
-
try:
|
19 |
-
img = cv2.imread(path)
|
20 |
-
if len(img.shape) == 2:
|
21 |
-
img = np.stack([img] * 3, 2)
|
22 |
-
return img
|
23 |
-
except IOError:
|
24 |
-
print('Cannot load image ' + path)
|
25 |
-
return None
|
26 |
-
|
27 |
-
|
28 |
-
class MegaFace(data.Dataset):
|
29 |
-
def __init__(self, facescrub_dir, megaface_dir, transform=None, loader=img_loader):
|
30 |
-
super().__init__()
|
31 |
-
self.transform = transform
|
32 |
-
self.loader = loader
|
33 |
-
|
34 |
-
test_image_file_list = []
|
35 |
-
print('Scanning files under facescrub and megaface...')
|
36 |
-
for root, _, files in os.walk(facescrub_dir):
|
37 |
-
for e in files:
|
38 |
-
filename = os.path.join(root, e)
|
39 |
-
ext = os.path.splitext(filename)[1].lower()
|
40 |
-
if ext in ('.png', '.bmp', '.jpg', '.jpeg'):
|
41 |
-
test_image_file_list.append(filename)
|
42 |
-
for root, _, files in os.walk(megaface_dir):
|
43 |
-
for e in files:
|
44 |
-
filename = os.path.join(root, e)
|
45 |
-
ext = os.path.splitext(filename)[1].lower()
|
46 |
-
if ext in ('.png', '.bmp', '.jpg', '.jpeg'):
|
47 |
-
test_image_file_list.append(filename)
|
48 |
-
|
49 |
-
self.image_list = test_image_file_list
|
50 |
-
|
51 |
-
def __getitem__(self, index):
|
52 |
-
img_path = self.image_list[index]
|
53 |
-
img = self.loader(img_path)
|
54 |
-
|
55 |
-
#水平翻转图像
|
56 |
-
#img = cv2.flip(img, 1)
|
57 |
-
|
58 |
-
if self.transform is not None:
|
59 |
-
img = self.transform(img)
|
60 |
-
else:
|
61 |
-
img = torch.from_numpy(img)
|
62 |
-
|
63 |
-
return img, img_path
|
64 |
-
|
65 |
-
def __len__(self):
|
66 |
-
return len(self.image_list)
|
67 |
-
|
68 |
-
|
69 |
-
if __name__ == '__main__':
|
70 |
-
facescrub = '/media/sda/megaface_test_kit/facescrub_align_112/'
|
71 |
-
megaface = '/media/sda/megaface_test_kit/megaface_align_112/'
|
72 |
-
|
73 |
-
transform = transforms.Compose([
|
74 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
75 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
76 |
-
])
|
77 |
-
dataset = MegaFace(facescrub, megaface, transform=transform)
|
78 |
-
trainloader = data.DataLoader(dataset, batch_size=64, shuffle=False, num_workers=2, drop_last=False)
|
79 |
-
print(len(dataset))
|
80 |
-
for data in trainloader:
|
81 |
-
print(data.shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/datasets/__init__.py
DELETED
File without changes
|
face_recognition1/face_feature/datasets/prepare_dataset.py
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
"""
|
2 |
-
@author: MingDong
|
3 |
-
@file: prepare_dataset.py
|
4 |
-
@desc: merge the face align images (112x112)
|
5 |
-
"""
|
6 |
-
import sys
|
7 |
-
|
8 |
-
import cv2
|
9 |
-
|
10 |
-
sys.path.append('../..')
|
11 |
-
|
12 |
-
import os
|
13 |
-
import argparse
|
14 |
-
from tqdm import tqdm
|
15 |
-
from face_liveness.datasets.prepare_dataset import get_file_names
|
16 |
-
from face_detect.test import get_bbox
|
17 |
-
from face_pose.test import get_pose
|
18 |
-
from feature_api import align
|
19 |
-
|
20 |
-
parser = argparse.ArgumentParser(description='split or merge')
|
21 |
-
parser.add_argument('--file_name', default='./glink360k/train.rec', help='source file name')
|
22 |
-
parser.add_argument('--start_no', type=int, default=1, help='start number for merge')
|
23 |
-
parser.add_argument('--end_no', type=int, default=34, help='end number for merge')
|
24 |
-
parser.add_argument('--remove', default=False, help='Flag for Remove')
|
25 |
-
parser.add_argument('--split_size', type=int, default=80000000, help='split file size')
|
26 |
-
parser.add_argument('--db_path', default='/datasets/public2/upload/faces_emore_images', help='source file name')
|
27 |
-
parser.add_argument('--label_file', default='/datasets/public2/upload/faces_emore/faces_emore.list', help='source file name')
|
28 |
-
|
29 |
-
args = parser.parse_args()
|
30 |
-
|
31 |
-
|
32 |
-
def merge_files(args):
|
33 |
-
""" merge the split files in Azure """
|
34 |
-
with open(args.file_name, 'ab') as f:
|
35 |
-
for i in range(args.start_no, args.end_no + 1):
|
36 |
-
fn = args.file_name + str(i) + '.rar'
|
37 |
-
with open(fn, 'rb') as chunk_file:
|
38 |
-
f.write(chunk_file.read())
|
39 |
-
if args.remove:
|
40 |
-
os.remove(fn)
|
41 |
-
print(fn)
|
42 |
-
|
43 |
-
print('ok')
|
44 |
-
|
45 |
-
|
46 |
-
def split_files(args):
|
47 |
-
file_number = 1
|
48 |
-
with open(args.file_name, 'rb') as f:
|
49 |
-
chunk = f.read(args.split_size)
|
50 |
-
while chunk:
|
51 |
-
with open(args.file_name + str(file_number) + '.rar', 'wb') as chunk_file:
|
52 |
-
chunk_file.write(chunk)
|
53 |
-
file_number += 1
|
54 |
-
chunk = f.read(args.split_size)
|
55 |
-
|
56 |
-
print('ok')
|
57 |
-
|
58 |
-
|
59 |
-
def generate_train_label_file(args):
|
60 |
-
label_list = []
|
61 |
-
file_list = get_file_names(args.db_path)
|
62 |
-
class_idx = -1
|
63 |
-
dir_list = []
|
64 |
-
for file_path in tqdm(file_list):
|
65 |
-
dirname = os.path.basename(os.path.dirname(file_path))
|
66 |
-
if dirname not in dir_list:
|
67 |
-
dir_list.append(dirname)
|
68 |
-
class_idx += 1
|
69 |
-
|
70 |
-
label_list.append(f'{file_path} {class_idx}\n')
|
71 |
-
|
72 |
-
with open(args.label_file, 'w') as f:
|
73 |
-
f.writelines(label_list)
|
74 |
-
|
75 |
-
|
76 |
-
def align_files(args):
|
77 |
-
""" align face images from the indian dataset and use it as the training dataset for feature extraction """
|
78 |
-
file_list = get_file_names(args.db_path)
|
79 |
-
for path in tqdm(file_list):
|
80 |
-
image = cv2.imread(path)
|
81 |
-
|
82 |
-
face_bbox = get_bbox(image)
|
83 |
-
if face_bbox is None:
|
84 |
-
continue
|
85 |
-
|
86 |
-
yaw, pitch, roll = get_pose(image, face_bbox)
|
87 |
-
if abs(yaw.item()) > 25 or abs(pitch.item()) > 25 or abs(roll.item()) > 25:
|
88 |
-
continue
|
89 |
-
|
90 |
-
face_image = align(image, output_size=(112, 112))
|
91 |
-
dst_path = path.replace('indian_images', 'indian_align_images')
|
92 |
-
if not os.path.exists(os.path.dirname(dst_path)):
|
93 |
-
os.makedirs(os.path.dirname(dst_path))
|
94 |
-
|
95 |
-
if face_image is not None:
|
96 |
-
cv2.imwrite(dst_path, face_image)
|
97 |
-
|
98 |
-
|
99 |
-
def rename_umd(args):
|
100 |
-
""" rename folder name for umd dataset """
|
101 |
-
folders = os.listdir(args.db_path)
|
102 |
-
for folder in folders:
|
103 |
-
os.rename(os.path.join(args.db_path, folder), f'{args.db_path}/umd{folder}')
|
104 |
-
|
105 |
-
|
106 |
-
if __name__ == '__main__':
|
107 |
-
# merge_files(args)
|
108 |
-
# split_files(args)
|
109 |
-
# align_files(args)
|
110 |
-
# generate_train_label_file(args)
|
111 |
-
rename_umd(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_agedb30.py
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: eval_agedb30.py
|
6 |
-
@desc: The AgeDB-30 test protocol is same with LFW, so I just copy the code from eval_lfw.py
|
7 |
-
'''
|
8 |
-
|
9 |
-
|
10 |
-
import os
|
11 |
-
import argparse
|
12 |
-
import numpy as np
|
13 |
-
import scipy.io
|
14 |
-
import torch.utils.data
|
15 |
-
import torchvision.transforms as transforms
|
16 |
-
from torch.nn import DataParallel
|
17 |
-
from model import mobilefacenet, cbam
|
18 |
-
from dataloader.agedb import AgeDB30
|
19 |
-
|
20 |
-
|
21 |
-
def getAccuracy(scores, flags, threshold):
|
22 |
-
p = np.sum(scores[flags == 1] > threshold)
|
23 |
-
n = np.sum(scores[flags == -1] < threshold)
|
24 |
-
return 1.0 * (p + n) / len(scores)
|
25 |
-
|
26 |
-
def getThreshold(scores, flags, thrNum):
|
27 |
-
accuracys = np.zeros((2 * thrNum + 1, 1))
|
28 |
-
thresholds = np.arange(-thrNum, thrNum + 1) * 1.0 / thrNum
|
29 |
-
for i in range(2 * thrNum + 1):
|
30 |
-
accuracys[i] = getAccuracy(scores, flags, thresholds[i])
|
31 |
-
max_index = np.squeeze(accuracys == np.max(accuracys))
|
32 |
-
bestThreshold = np.mean(thresholds[max_index])
|
33 |
-
return bestThreshold
|
34 |
-
|
35 |
-
def evaluation_10_fold(feature_path='./result/cur_epoch_agedb_result.mat'):
|
36 |
-
ACCs = np.zeros(10)
|
37 |
-
result = scipy.io.loadmat(feature_path)
|
38 |
-
for i in range(10):
|
39 |
-
fold = result['fold']
|
40 |
-
flags = result['flag']
|
41 |
-
featureLs = result['fl']
|
42 |
-
featureRs = result['fr']
|
43 |
-
|
44 |
-
valFold = fold != i
|
45 |
-
testFold = fold == i
|
46 |
-
flags = np.squeeze(flags)
|
47 |
-
|
48 |
-
mu = np.mean(np.concatenate((featureLs[valFold[0], :], featureRs[valFold[0], :]), 0), 0)
|
49 |
-
mu = np.expand_dims(mu, 0)
|
50 |
-
featureLs = featureLs - mu
|
51 |
-
featureRs = featureRs - mu
|
52 |
-
featureLs = featureLs / np.expand_dims(np.sqrt(np.sum(np.power(featureLs, 2), 1)), 1)
|
53 |
-
featureRs = featureRs / np.expand_dims(np.sqrt(np.sum(np.power(featureRs, 2), 1)), 1)
|
54 |
-
|
55 |
-
scores = np.sum(np.multiply(featureLs, featureRs), 1)
|
56 |
-
threshold = getThreshold(scores[valFold[0]], flags[valFold[0]], 10000)
|
57 |
-
ACCs[i] = getAccuracy(scores[testFold[0]], flags[testFold[0]], threshold)
|
58 |
-
|
59 |
-
return ACCs
|
60 |
-
|
61 |
-
def loadModel(data_root, file_list, backbone_net, gpus='0', resume=None):
|
62 |
-
|
63 |
-
if backbone_net == 'MobileFace':
|
64 |
-
net = mobilefacenet.MobileFaceNet()
|
65 |
-
elif backbone_net == 'CBAM_50':
|
66 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir')
|
67 |
-
elif backbone_net == 'CBAM_50_SE':
|
68 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir_se')
|
69 |
-
elif backbone_net == 'CBAM_100':
|
70 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir')
|
71 |
-
elif backbone_net == 'CBAM_100_SE':
|
72 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir_se')
|
73 |
-
else:
|
74 |
-
print(backbone_net, ' is not available!')
|
75 |
-
|
76 |
-
# gpu init
|
77 |
-
multi_gpus = False
|
78 |
-
if len(gpus.split(',')) > 1:
|
79 |
-
multi_gpus = True
|
80 |
-
os.environ['CUDA_VISIBLE_DEVICES'] = gpus
|
81 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
82 |
-
|
83 |
-
net.load_state_dict(torch.load(resume)['net_state_dict'])
|
84 |
-
|
85 |
-
if multi_gpus:
|
86 |
-
net = DataParallel(net).to(device)
|
87 |
-
else:
|
88 |
-
net = net.to(device)
|
89 |
-
|
90 |
-
transform = transforms.Compose([
|
91 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
92 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
93 |
-
])
|
94 |
-
agedb_dataset = AgeDB30(data_root, file_list, transform=transform)
|
95 |
-
agedb_loader = torch.utils.data.DataLoader(agedb_dataset, batch_size=128,
|
96 |
-
shuffle=False, num_workers=2, drop_last=False)
|
97 |
-
|
98 |
-
return net.eval(), device, agedb_dataset, agedb_loader
|
99 |
-
|
100 |
-
def getFeatureFromTorch(feature_save_dir, net, device, data_set, data_loader):
|
101 |
-
featureLs = None
|
102 |
-
featureRs = None
|
103 |
-
count = 0
|
104 |
-
for data in data_loader:
|
105 |
-
for _, i in enumerate(data):
|
106 |
-
data[i] = data[i].to(device)
|
107 |
-
count += data[0].size(0)
|
108 |
-
#print('extracing deep features from the face pair {}...'.format(count))
|
109 |
-
with torch.no_grad():
|
110 |
-
res = [net(d).data.cpu().numpy() for d in data]
|
111 |
-
featureL = np.concatenate((res[0], res[1]), 1)
|
112 |
-
featureR = np.concatenate((res[2], res[3]), 1)
|
113 |
-
# print(featureL.shape, featureR.shape)
|
114 |
-
if featureLs is None:
|
115 |
-
featureLs = featureL
|
116 |
-
else:
|
117 |
-
featureLs = np.concatenate((featureLs, featureL), 0)
|
118 |
-
if featureRs is None:
|
119 |
-
featureRs = featureR
|
120 |
-
else:
|
121 |
-
featureRs = np.concatenate((featureRs, featureR), 0)
|
122 |
-
# print(featureLs.shape, featureRs.shape)
|
123 |
-
|
124 |
-
result = {'fl': featureLs, 'fr': featureRs, 'fold': data_set.folds, 'flag': data_set.flags}
|
125 |
-
scipy.io.savemat(feature_save_dir, result)
|
126 |
-
|
127 |
-
|
128 |
-
if __name__ == '__main__':
|
129 |
-
parser = argparse.ArgumentParser(description='Testing')
|
130 |
-
parser.add_argument('--root', type=str, default='/media/sda/AgeDB-30/agedb30_align_112', help='The path of lfw data')
|
131 |
-
parser.add_argument('--file_list', type=str, default='/media/sda/AgeDB-30/agedb_30_pair.txt', help='The path of lfw data')
|
132 |
-
parser.add_argument('--resume', type=str, default='./model/SERES100_SERES100_IR_20190528_132635/Iter_342000_net.ckpt', help='The path pf save model')
|
133 |
-
parser.add_argument('--backbone_net', type=str, default='CBAM_100_SE', help='MobileFace, CBAM_50, CBAM_50_SE, CBAM_100, CBAM_100_SE')
|
134 |
-
parser.add_argument('--feature_dim', type=int, default=512, help='feature dimension')
|
135 |
-
parser.add_argument('--feature_save_path', type=str, default='./result/cur_epoch_agedb_result.mat',
|
136 |
-
help='The path of the extract features save, must be .mat file')
|
137 |
-
parser.add_argument('--gpus', type=str, default='2,3', help='gpu list')
|
138 |
-
args = parser.parse_args()
|
139 |
-
|
140 |
-
net, device, agedb_dataset, agedb_loader = loadModel(args.root, args.file_list, args.backbone_net, args.gpus, args.resume)
|
141 |
-
getFeatureFromTorch(args.feature_save_path, net, device, agedb_dataset, agedb_loader)
|
142 |
-
ACCs = evaluation_10_fold(args.feature_save_path)
|
143 |
-
for _, i in enumerate(ACCs):
|
144 |
-
print(f'{i + 1} {ACCs[i] * 100:.2f}')
|
145 |
-
print('--------')
|
146 |
-
print(f'AVE {np.mean(ACCs) * 100:.4f}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_cfp.py
DELETED
@@ -1,143 +0,0 @@
|
|
1 |
-
"""
|
2 |
-
@author: MingDong
|
3 |
-
@file: eval_cfp.py
|
4 |
-
@desc: this code is very similar with eval_lfw.py and eval_agedb30.py
|
5 |
-
"""
|
6 |
-
import os
|
7 |
-
import argparse
|
8 |
-
import numpy as np
|
9 |
-
import scipy.io
|
10 |
-
import torch.utils.data
|
11 |
-
import torchvision.transforms as transforms
|
12 |
-
from torch.nn import DataParallel
|
13 |
-
from model import mobilefacenet, cbam
|
14 |
-
from dataloader.cfp import CFP_FP
|
15 |
-
|
16 |
-
|
17 |
-
def getAccuracy(scores, flags, threshold):
|
18 |
-
p = np.sum(scores[flags == 1] > threshold)
|
19 |
-
n = np.sum(scores[flags == -1] < threshold)
|
20 |
-
return 1.0 * (p + n) / len(scores)
|
21 |
-
|
22 |
-
|
23 |
-
def getThreshold(scores, flags, thrNum):
|
24 |
-
accuracys = np.zeros((2 * thrNum + 1, 1))
|
25 |
-
thresholds = np.arange(-thrNum, thrNum + 1) * 1.0 / thrNum
|
26 |
-
for i in range(2 * thrNum + 1):
|
27 |
-
accuracys[i] = getAccuracy(scores, flags, thresholds[i])
|
28 |
-
max_index = np.squeeze(accuracys == np.max(accuracys))
|
29 |
-
bestThreshold = np.mean(thresholds[max_index])
|
30 |
-
return bestThreshold
|
31 |
-
|
32 |
-
def evaluation_10_fold(feature_path='./result/cur_epoch_cfp_result.mat'):
|
33 |
-
ACCs = np.zeros(10)
|
34 |
-
result = scipy.io.loadmat(feature_path)
|
35 |
-
for i in range(10):
|
36 |
-
fold = result['fold']
|
37 |
-
flags = result['flag']
|
38 |
-
featureLs = result['fl']
|
39 |
-
featureRs = result['fr']
|
40 |
-
|
41 |
-
valFold = fold != i
|
42 |
-
testFold = fold == i
|
43 |
-
flags = np.squeeze(flags)
|
44 |
-
|
45 |
-
mu = np.mean(np.concatenate((featureLs[valFold[0], :], featureRs[valFold[0], :]), 0), 0)
|
46 |
-
mu = np.expand_dims(mu, 0)
|
47 |
-
featureLs = featureLs - mu
|
48 |
-
featureRs = featureRs - mu
|
49 |
-
featureLs = featureLs / np.expand_dims(np.sqrt(np.sum(np.power(featureLs, 2), 1)), 1)
|
50 |
-
featureRs = featureRs / np.expand_dims(np.sqrt(np.sum(np.power(featureRs, 2), 1)), 1)
|
51 |
-
|
52 |
-
scores = np.sum(np.multiply(featureLs, featureRs), 1)
|
53 |
-
threshold = getThreshold(scores[valFold[0]], flags[valFold[0]], 10000)
|
54 |
-
ACCs[i] = getAccuracy(scores[testFold[0]], flags[testFold[0]], threshold)
|
55 |
-
|
56 |
-
return ACCs
|
57 |
-
|
58 |
-
def loadModel(data_root, file_list, backbone_net, gpus='0', resume=None):
|
59 |
-
|
60 |
-
if backbone_net == 'MobileFace':
|
61 |
-
net = mobilefacenet.MobileFaceNet()
|
62 |
-
elif backbone_net == 'CBAM_50':
|
63 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir')
|
64 |
-
elif backbone_net == 'CBAM_50_SE':
|
65 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir_se')
|
66 |
-
elif backbone_net == 'CBAM_100':
|
67 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir')
|
68 |
-
elif backbone_net == 'CBAM_100_SE':
|
69 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir_se')
|
70 |
-
else:
|
71 |
-
print(backbone_net, ' is not available!')
|
72 |
-
|
73 |
-
# gpu init
|
74 |
-
multi_gpus = False
|
75 |
-
if len(gpus.split(',')) > 1:
|
76 |
-
multi_gpus = True
|
77 |
-
os.environ['CUDA_VISIBLE_DEVICES'] = gpus
|
78 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
79 |
-
|
80 |
-
net.load_state_dict(torch.load(resume)['net_state_dict'])
|
81 |
-
|
82 |
-
if multi_gpus:
|
83 |
-
net = DataParallel(net).to(device)
|
84 |
-
else:
|
85 |
-
net = net.to(device)
|
86 |
-
|
87 |
-
transform = transforms.Compose([
|
88 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
89 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
90 |
-
])
|
91 |
-
cfp_dataset = CFP_FP(data_root, file_list, transform=transform)
|
92 |
-
cfp_loader = torch.utils.data.DataLoader(cfp_dataset, batch_size=128,
|
93 |
-
shuffle=False, num_workers=4, drop_last=False)
|
94 |
-
|
95 |
-
return net.eval(), device, cfp_dataset, cfp_loader
|
96 |
-
|
97 |
-
def getFeatureFromTorch(feature_save_dir, net, device, data_set, data_loader):
|
98 |
-
featureLs = None
|
99 |
-
featureRs = None
|
100 |
-
count = 0
|
101 |
-
for data in data_loader:
|
102 |
-
for _, i in enumerate(data):
|
103 |
-
data[i] = data[i].to(device)
|
104 |
-
count += data[0].size(0)
|
105 |
-
#print('extracing deep features from the face pair {}...'.format(count))
|
106 |
-
with torch.no_grad():
|
107 |
-
res = [net(d).data.cpu().numpy() for d in data]
|
108 |
-
featureL = np.concatenate((res[0], res[1]), 1)
|
109 |
-
featureR = np.concatenate((res[2], res[3]), 1)
|
110 |
-
# print(featureL.shape, featureR.shape)
|
111 |
-
if featureLs is None:
|
112 |
-
featureLs = featureL
|
113 |
-
else:
|
114 |
-
featureLs = np.concatenate((featureLs, featureL), 0)
|
115 |
-
if featureRs is None:
|
116 |
-
featureRs = featureR
|
117 |
-
else:
|
118 |
-
featureRs = np.concatenate((featureRs, featureR), 0)
|
119 |
-
# print(featureLs.shape, featureRs.shape)
|
120 |
-
|
121 |
-
result = {'fl': featureLs, 'fr': featureRs, 'fold': data_set.folds, 'flag': data_set.flags}
|
122 |
-
scipy.io.savemat(feature_save_dir, result)
|
123 |
-
|
124 |
-
|
125 |
-
if __name__ == '__main__':
|
126 |
-
parser = argparse.ArgumentParser(description='Testing')
|
127 |
-
parser.add_argument('--root', type=str, default='/media/sda/CFP-FP/cfp_fp_aligned_112', help='The path of lfw data')
|
128 |
-
parser.add_argument('--file_list', type=str, default='/media/sda/CFP-FP/cfp_fp_pair.txt', help='The path of lfw data')
|
129 |
-
parser.add_argument('--resume', type=str, default='./checkpoints/SERES100_SERES100_IR_20190528_132635/Iter_342000_net.ckpt', help='The path pf save checkpoints')
|
130 |
-
parser.add_argument('--backbone_net', type=str, default='CBAM_100_SE', help='MobileFace, CBAM_50, CBAM_50_SE, CBAM_100, CBAM_100_SE')
|
131 |
-
parser.add_argument('--feature_dim', type=int, default=512, help='feature dimension')
|
132 |
-
parser.add_argument('--feature_save_path', type=str, default='./result/cur_epoch_cfp_result.mat',
|
133 |
-
help='The path of the extract features save, must be .mat file')
|
134 |
-
parser.add_argument('--gpus', type=str, default='2,3', help='gpu list')
|
135 |
-
args = parser.parse_args()
|
136 |
-
|
137 |
-
net, device, agedb_dataset, agedb_loader = loadModel(args.root, args.file_list, args.backbone_net, args.gpus, args.resume)
|
138 |
-
getFeatureFromTorch(args.feature_save_path, net, device, agedb_dataset, agedb_loader)
|
139 |
-
ACCs = evaluation_10_fold(args.feature_save_path)
|
140 |
-
for _, i in enumerate(ACCs):
|
141 |
-
print(f'{i + 1} {ACCs[i] * 100:.2f}')
|
142 |
-
print('--------')
|
143 |
-
print(f'AVE {np.mean(ACCs) * 100:.4f}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_deepglint_merge.py
DELETED
@@ -1,101 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
"""
|
4 |
-
@author: MingDong
|
5 |
-
@file: eval_deepglint_merge.py.py
|
6 |
-
@desc: merge the feature of deepglint test data to one file. original deepglint feature is generated by the protocol of megaface.
|
7 |
-
|
8 |
-
We use the same format as Megaface(http://megaface.cs.washington.edu)
|
9 |
-
except that we merge all files into a single binary file.
|
10 |
-
|
11 |
-
for examples:
|
12 |
-
|
13 |
-
when megaface: N * (512, 1)
|
14 |
-
while deepglint:(N, 512)
|
15 |
-
|
16 |
-
"""
|
17 |
-
import os
|
18 |
-
import argparse
|
19 |
-
import struct
|
20 |
-
import numpy as np
|
21 |
-
|
22 |
-
cv_type_to_dtype = {
|
23 |
-
5: np.dtype('float32')
|
24 |
-
}
|
25 |
-
|
26 |
-
dtype_to_cv_type = {v: k for k, v in cv_type_to_dtype.items()}
|
27 |
-
|
28 |
-
|
29 |
-
def write_mat(f, m):
|
30 |
-
"""Write mat m to file f"""
|
31 |
-
if len(m.shape) == 1:
|
32 |
-
rows = m.shape[0]
|
33 |
-
cols = 1
|
34 |
-
else:
|
35 |
-
rows, cols = m.shape
|
36 |
-
header = struct.pack('iiii', rows, cols, cols * 4, dtype_to_cv_type[m.dtype])
|
37 |
-
f.write(header)
|
38 |
-
f.write(m.data)
|
39 |
-
|
40 |
-
|
41 |
-
def read_mat(f):
|
42 |
-
"""
|
43 |
-
Reads an OpenCV mat from the given file opened in binary mode
|
44 |
-
"""
|
45 |
-
rows, cols, stride, type_ = struct.unpack('iiii', f.read(4 * 4))
|
46 |
-
mat = np.fromstring(f.read(rows * stride), dtype=cv_type_to_dtype[type_])
|
47 |
-
return mat.reshape(rows, cols)
|
48 |
-
|
49 |
-
|
50 |
-
def load_mat(filename):
|
51 |
-
"""
|
52 |
-
Reads a OpenCV Mat from the given filename
|
53 |
-
"""
|
54 |
-
return read_mat(open(filename, 'rb'))
|
55 |
-
|
56 |
-
|
57 |
-
def save_mat(filename, m):
|
58 |
-
"""Saves mat m to the given filename"""
|
59 |
-
return write_mat(open(filename, 'wb'), m)
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
def main(args):
|
64 |
-
|
65 |
-
deepglint_features = args.deepglint_features_path
|
66 |
-
# merge all features into one file
|
67 |
-
total_feature = []
|
68 |
-
total_files = []
|
69 |
-
for root, _, files in os.walk(deepglint_features):
|
70 |
-
for file in files:
|
71 |
-
filename = os.path.join(root, file)
|
72 |
-
ext = os.path.splitext(filename)[1]
|
73 |
-
ext = ext.lower()
|
74 |
-
if ext in ('.feat'):
|
75 |
-
total_files.append(filename)
|
76 |
-
|
77 |
-
assert len(total_files) == 1862120
|
78 |
-
total_files.sort() # important
|
79 |
-
|
80 |
-
for _, i in enumerate(total_files):
|
81 |
-
filename = total_files[i]
|
82 |
-
tmp_feature = load_mat(filename)
|
83 |
-
# print(filename)
|
84 |
-
# print(tmp_feature.shape)
|
85 |
-
tmp_feature = tmp_feature.T
|
86 |
-
total_feature.append(tmp_feature)
|
87 |
-
print(i + 1, tmp_feature.shape)
|
88 |
-
# write_mat(feature_path_out, feature_fusion)
|
89 |
-
|
90 |
-
print('total feature number: ', len(total_feature))
|
91 |
-
total_feature = np.array(total_feature).squeeze()
|
92 |
-
print(total_feature.shape, total_feature.dtype, type(total_feature))
|
93 |
-
save_mat('deepglint_test_feature.bin', total_feature)
|
94 |
-
|
95 |
-
|
96 |
-
if __name__ == '__main__':
|
97 |
-
parser = argparse.ArgumentParser()
|
98 |
-
parser.add_argument("--deepglint_features_path", type=str, default="/home/mingdong/deepglint/deepglint_feature_ir+ws/")
|
99 |
-
args = parser.parse_args()
|
100 |
-
|
101 |
-
main(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_lfw.py
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
"""
|
4 |
-
@author: MingDong
|
5 |
-
@file: eval_lfw.py
|
6 |
-
@desc:
|
7 |
-
"""
|
8 |
-
|
9 |
-
import os
|
10 |
-
import argparse
|
11 |
-
import numpy as np
|
12 |
-
import scipy.io
|
13 |
-
import onnxruntime as ort
|
14 |
-
import torch.utils.data
|
15 |
-
import torchvision.transforms as transforms
|
16 |
-
from torch.nn import DataParallel
|
17 |
-
from model import mobilefacenet, resnet, cbam
|
18 |
-
from dataloader.lfw import LFW, LFWDataset
|
19 |
-
|
20 |
-
|
21 |
-
def getAccuracy(scores, flags, threshold):
|
22 |
-
p = np.sum(scores[flags == 1] > threshold)
|
23 |
-
n = np.sum(scores[flags == -1] < threshold)
|
24 |
-
return 1.0 * (p + n) / len(scores)
|
25 |
-
|
26 |
-
def getThreshold(scores, flags, thrNum):
|
27 |
-
accuracys = np.zeros((2 * thrNum + 1, 1))
|
28 |
-
thresholds = np.arange(-thrNum, thrNum + 1) * 1.0 / thrNum
|
29 |
-
for i in range(2 * thrNum + 1):
|
30 |
-
accuracys[i] = getAccuracy(scores, flags, thresholds[i])
|
31 |
-
max_index = np.squeeze(accuracys == np.max(accuracys))
|
32 |
-
bestThreshold = np.mean(thresholds[max_index])
|
33 |
-
return bestThreshold
|
34 |
-
|
35 |
-
def evaluation_10_fold(feature_path='./result/cur_epoch_result.mat'):
|
36 |
-
ACCs = np.zeros(10)
|
37 |
-
result = scipy.io.loadmat(feature_path)
|
38 |
-
for i in range(10):
|
39 |
-
fold = result['fold']
|
40 |
-
flags = result['flag']
|
41 |
-
featureLs = result['fl']
|
42 |
-
featureRs = result['fr']
|
43 |
-
|
44 |
-
valFold = fold != i
|
45 |
-
testFold = fold == i
|
46 |
-
flags = np.squeeze(flags)
|
47 |
-
|
48 |
-
mu = np.mean(np.concatenate((featureLs[valFold[0], :], featureRs[valFold[0], :]), 0), 0)
|
49 |
-
mu = np.expand_dims(mu, 0)
|
50 |
-
featureLs = featureLs - mu
|
51 |
-
featureRs = featureRs - mu
|
52 |
-
featureLs = featureLs / np.expand_dims(np.sqrt(np.sum(np.power(featureLs, 2), 1)), 1)
|
53 |
-
featureRs = featureRs / np.expand_dims(np.sqrt(np.sum(np.power(featureRs, 2), 1)), 1)
|
54 |
-
|
55 |
-
scores = np.sum(np.multiply(featureLs, featureRs), 1)
|
56 |
-
threshold = getThreshold(scores[valFold[0]], flags[valFold[0]], 10000)
|
57 |
-
ACCs[i] = getAccuracy(scores[testFold[0]], flags[testFold[0]], threshold)
|
58 |
-
|
59 |
-
return ACCs
|
60 |
-
|
61 |
-
|
62 |
-
def load_model(data_root, file_list, backbone_net, gpus='0', resume=None):
|
63 |
-
|
64 |
-
if backbone_net == 'MobileFace':
|
65 |
-
net = mobilefacenet.MobileFaceNet()
|
66 |
-
elif backbone_net == 'Res50':
|
67 |
-
net = resnet.ResNet50()
|
68 |
-
elif backbone_net == 'CBAM_50':
|
69 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir')
|
70 |
-
elif backbone_net == 'CBAM_50_SE':
|
71 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir_se')
|
72 |
-
elif backbone_net == 'CBAM_100':
|
73 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir')
|
74 |
-
elif backbone_net == 'CBAM_100_SE':
|
75 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir_se')
|
76 |
-
else:
|
77 |
-
print(backbone_net, ' is not available!')
|
78 |
-
|
79 |
-
# gpu init
|
80 |
-
multi_gpus = False
|
81 |
-
if len(gpus.split(',')) > 1:
|
82 |
-
multi_gpus = True
|
83 |
-
os.environ['CUDA_VISIBLE_DEVICES'] = gpus
|
84 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
85 |
-
|
86 |
-
net.load_state_dict(torch.load(resume)['net_state_dict'])
|
87 |
-
|
88 |
-
if multi_gpus:
|
89 |
-
net = DataParallel(net).to(device)
|
90 |
-
else:
|
91 |
-
net = net.to(device)
|
92 |
-
|
93 |
-
transform = transforms.Compose([
|
94 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
95 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
96 |
-
])
|
97 |
-
lfw_dataset = LFW(data_root, file_list, transform=transform)
|
98 |
-
lfw_loader = torch.utils.data.DataLoader(lfw_dataset, batch_size=128,
|
99 |
-
shuffle=False, num_workers=2, drop_last=False)
|
100 |
-
|
101 |
-
return net.eval(), device, lfw_dataset, lfw_loader
|
102 |
-
|
103 |
-
|
104 |
-
def load_onnx_model(data_root, file_list):
|
105 |
-
ort_session = ort.InferenceSession('checkpoints/resnet50_Quant.onnx')
|
106 |
-
|
107 |
-
lfw_dataset = LFWDataset(data_root, file_list)
|
108 |
-
|
109 |
-
return ort_session, lfw_dataset
|
110 |
-
|
111 |
-
|
112 |
-
def getFeatureFromTorch(feature_save_dir, net, device, data_set, data_loader):
|
113 |
-
featureLs = None
|
114 |
-
featureRs = None
|
115 |
-
count = 0
|
116 |
-
for data in data_loader:
|
117 |
-
for i, _ in enumerate(data):
|
118 |
-
data[i] = data[i].to(device)
|
119 |
-
count += data[0].size(0)
|
120 |
-
#print('extracing deep features from the face pair {}...'.format(count))
|
121 |
-
with torch.no_grad():
|
122 |
-
res = [net(d).data.cpu().numpy() for d in data]
|
123 |
-
featureL = np.concatenate((res[0], res[1]), 1)
|
124 |
-
featureR = np.concatenate((res[2], res[3]), 1)
|
125 |
-
# print(featureL.shape, featureR.shape)
|
126 |
-
if featureLs is None:
|
127 |
-
featureLs = featureL
|
128 |
-
else:
|
129 |
-
featureLs = np.concatenate((featureLs, featureL), 0)
|
130 |
-
if featureRs is None:
|
131 |
-
featureRs = featureR
|
132 |
-
else:
|
133 |
-
featureRs = np.concatenate((featureRs, featureR), 0)
|
134 |
-
# print(featureLs.shape, featureRs.shape)
|
135 |
-
|
136 |
-
result = {'fl': featureLs, 'fr': featureRs, 'fold': data_set.folds, 'flag': data_set.flags}
|
137 |
-
scipy.io.savemat(feature_save_dir, result)
|
138 |
-
|
139 |
-
|
140 |
-
def getFeatureFromOnnx(feature_save_dir, net, data_set):
|
141 |
-
featureLs = None
|
142 |
-
featureRs = None
|
143 |
-
count = 0
|
144 |
-
|
145 |
-
for data in data_set:
|
146 |
-
res = []
|
147 |
-
for _, i in enumerate(data):
|
148 |
-
feat = net.run(None, {"input": data[i]})
|
149 |
-
res.append(feat)
|
150 |
-
count += data[0].size(0)
|
151 |
-
|
152 |
-
featureL = np.concatenate((res[0], res[1]), 1)
|
153 |
-
featureR = np.concatenate((res[2], res[3]), 1)
|
154 |
-
# print(featureL.shape, featureR.shape)
|
155 |
-
if featureLs is None:
|
156 |
-
featureLs = featureL
|
157 |
-
else:
|
158 |
-
featureLs = np.concatenate((featureLs, featureL), 0)
|
159 |
-
if featureRs is None:
|
160 |
-
featureRs = featureR
|
161 |
-
else:
|
162 |
-
featureRs = np.concatenate((featureRs, featureR), 0)
|
163 |
-
# print(featureLs.shape, featureRs.shape)
|
164 |
-
|
165 |
-
result = {'fl': featureLs, 'fr': featureRs, 'fold': data_set.folds, 'flag': data_set.flags}
|
166 |
-
scipy.io.savemat(feature_save_dir, result)
|
167 |
-
|
168 |
-
|
169 |
-
if __name__ == '__main__':
|
170 |
-
parser = argparse.ArgumentParser(description='Testing')
|
171 |
-
parser.add_argument('--root', type=str, default='/datasets/public1/upload/datasets/lfw', help='The path of lfw data')
|
172 |
-
parser.add_argument('--file_list', type=str, default='/datasets/public1/upload/datasets/lfw_pair.txt', help='The path of lfw data')
|
173 |
-
parser.add_argument('--backbone_net', type=str, default='Res50', help='MobileFace, Res50, CBAM_50, CBAM_50_SE, CBAM_100, CBAM_100_SE')
|
174 |
-
parser.add_argument('--feature_dim', type=int, default=512, help='feature dimension')
|
175 |
-
parser.add_argument('--resume', type=str, default='./checkpoints/Res50_RES50_20210711_091848/Iter_066000_net.ckpt',
|
176 |
-
help='The path pf save checkpoints')
|
177 |
-
parser.add_argument('--feature_save_path', type=str, default='./result/cur_epoch_lfw_result.mat',
|
178 |
-
help='The path of the extract features save, must be .mat file')
|
179 |
-
parser.add_argument('--gpus', type=str, default='0', help='gpu list')
|
180 |
-
args = parser.parse_args()
|
181 |
-
|
182 |
-
# inference by torch
|
183 |
-
# net, device, lfw_dataset, lfw_loader = load_model(args.root, args.file_list, args.backbone_net, args.gpus, args.resume)
|
184 |
-
# getFeatureFromTorch(args.feature_save_path, net, device, lfw_dataset, lfw_loader)
|
185 |
-
# ACCs = evaluation_10_fold(args.feature_save_path)
|
186 |
-
|
187 |
-
# inference by onnx
|
188 |
-
net, lfw_dataset = load_onnx_model(args.root, args.file_list)
|
189 |
-
getFeatureFromOnnx(args.feature_save_path, net, lfw_dataset)
|
190 |
-
ACCs = evaluation_10_fold(args.feature_save_path)
|
191 |
-
|
192 |
-
for _, i in enumerate(ACCs):
|
193 |
-
print(f'{i + 1} {ACCs[i] * 100:.2f}')
|
194 |
-
print('--------')
|
195 |
-
print(f'AVE {np.mean(ACCs) * 100:.4f}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_lfw_blufr.py
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
"""
|
4 |
-
@author: MingDong
|
5 |
-
@file: eval_lfw_blufr.py
|
6 |
-
@desc: test lfw accuracy on blufr protocol
|
7 |
-
"""
|
8 |
-
|
9 |
-
import argparse
|
10 |
-
import scipy.io as sio
|
11 |
-
|
12 |
-
def readName(file='pairs.txt'):
|
13 |
-
name_list = []
|
14 |
-
f = open(file, 'r')
|
15 |
-
lines = f.readlines()
|
16 |
-
|
17 |
-
for line in lines[1:]:
|
18 |
-
line_split = line.rstrip().split()
|
19 |
-
if len(line_split) == 3:
|
20 |
-
name_list.append(line_split[0])
|
21 |
-
elif len(line_split) == 4:
|
22 |
-
name_list.append(line_split[0])
|
23 |
-
name_list.append(line_split[2])
|
24 |
-
else:
|
25 |
-
print('wrong file, please check again')
|
26 |
-
|
27 |
-
return list(set(name_list))
|
28 |
-
|
29 |
-
|
30 |
-
def main(args):
|
31 |
-
blufr_info = sio.loadmat(args.lfw_blufr_file)
|
32 |
-
#print(blufr_info)
|
33 |
-
name_list = readName()
|
34 |
-
|
35 |
-
image = blufr_info['imageList']
|
36 |
-
missing_files = []
|
37 |
-
for i in range(image.shape[0]):
|
38 |
-
name = image[i][0][0]
|
39 |
-
index = name.rfind('_')
|
40 |
-
name = name[0:index]
|
41 |
-
if name not in name_list:
|
42 |
-
print(name)
|
43 |
-
missing_files.append(name)
|
44 |
-
print('lfw pairs.txt total persons: ', len(name_list))
|
45 |
-
print('blufr_mat_missing persons: ', len(missing_files))
|
46 |
-
|
47 |
-
# Some of the missing file:
|
48 |
-
# Zdravko_Mucic
|
49 |
-
# Zelma_Novelo
|
50 |
-
# Zeng_Qinghong
|
51 |
-
# Zumrati_Juma
|
52 |
-
# lfw pairs.txt total persons: 4281
|
53 |
-
# blufr_mat_missing persons: 1549
|
54 |
-
|
55 |
-
|
56 |
-
if __name__ == '__main__':
|
57 |
-
parser = argparse.ArgumentParser(description='lfw blufr test')
|
58 |
-
parser.add_argument('--lfw_blufr_file', type=str, default='./blufr_lfw_config.mat', help='feature dimension')
|
59 |
-
parser.add_argument('--lfw_pairs.txt', type=str, default='./pairs.txt', help='feature dimension')
|
60 |
-
parser.add_argument('--gpus', type=str, default='2,3', help='gpu list')
|
61 |
-
args = parser.parse_args()
|
62 |
-
|
63 |
-
main(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/eval_megaface.py
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: eval_megaface.py
|
6 |
-
@desc: megaface feature extractor
|
7 |
-
'''
|
8 |
-
import os
|
9 |
-
import argparse
|
10 |
-
import struct
|
11 |
-
import numpy as np
|
12 |
-
import torch.utils.data
|
13 |
-
import torchvision.transforms as transforms
|
14 |
-
from torch.nn import DataParallel
|
15 |
-
from model import mobilefacenet, cbam
|
16 |
-
from dataloader.megaface import MegaFace
|
17 |
-
|
18 |
-
cv_type_to_dtype = {5: np.dtype('float32'), 6: np.dtype('float64')}
|
19 |
-
dtype_to_cv_type = {v: k for k, v in cv_type_to_dtype.items()}
|
20 |
-
|
21 |
-
|
22 |
-
def write_mat(filename, m):
|
23 |
-
"""Write mat m to file f"""
|
24 |
-
if len(m.shape) == 1:
|
25 |
-
rows = m.shape[0]
|
26 |
-
cols = 1
|
27 |
-
else:
|
28 |
-
rows, cols = m.shape
|
29 |
-
header = struct.pack('iiii', rows, cols, cols * 4, dtype_to_cv_type[m.dtype])
|
30 |
-
|
31 |
-
with open(filename, 'wb') as outfile:
|
32 |
-
outfile.write(header)
|
33 |
-
outfile.write(m.data)
|
34 |
-
|
35 |
-
|
36 |
-
def read_mat(filename):
|
37 |
-
"""
|
38 |
-
Reads an OpenCV mat from the given file opened in binary mode
|
39 |
-
"""
|
40 |
-
with open(filename, 'rb') as fin:
|
41 |
-
rows, cols, stride, type_ = struct.unpack('iiii', fin.read(4 * 4))
|
42 |
-
mat = np.fromstring(str(fin.read(rows * stride)), dtype=cv_type_to_dtype[type_])
|
43 |
-
return mat.reshape(rows, cols)
|
44 |
-
|
45 |
-
|
46 |
-
def extract_feature(model_path, backbone_net, face_scrub_path, megaface_path, batch_size=32, gpus='0', do_norm=False):
|
47 |
-
|
48 |
-
if backbone_net == 'MobileFace':
|
49 |
-
net = mobilefacenet.MobileFaceNet()
|
50 |
-
elif backbone_net == 'CBAM_50':
|
51 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir')
|
52 |
-
elif backbone_net == 'CBAM_50_SE':
|
53 |
-
net = cbam.CBAMResNet(50, feature_dim=args.feature_dim, mode='ir_se')
|
54 |
-
elif backbone_net == 'CBAM_100':
|
55 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir')
|
56 |
-
elif backbone_net == 'CBAM_100_SE':
|
57 |
-
net = cbam.CBAMResNet(100, feature_dim=args.feature_dim, mode='ir_se')
|
58 |
-
else:
|
59 |
-
print(args.backbone, ' is not available!')
|
60 |
-
|
61 |
-
multi_gpus = False
|
62 |
-
if len(gpus.split(',')) > 1:
|
63 |
-
multi_gpus = True
|
64 |
-
os.environ['CUDA_VISIBLE_DEVICES'] = gpus
|
65 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
66 |
-
|
67 |
-
net.load_state_dict(torch.load(model_path)['net_state_dict'])
|
68 |
-
if multi_gpus:
|
69 |
-
net = DataParallel(net).to(device)
|
70 |
-
else:
|
71 |
-
net = net.to(device)
|
72 |
-
net.eval()
|
73 |
-
|
74 |
-
transform = transforms.Compose([
|
75 |
-
transforms.ToTensor(), # range [0, 255] -> [0.0,1.0]
|
76 |
-
transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) # range [0.0, 1.0] -> [-1.0,1.0]
|
77 |
-
])
|
78 |
-
megaface_dataset = MegaFace(face_scrub_path, megaface_path, transform=transform)
|
79 |
-
megaface_loader = torch.utils.data.DataLoader(megaface_dataset, batch_size=batch_size,
|
80 |
-
shuffle=False, num_workers=12, drop_last=False)
|
81 |
-
|
82 |
-
for data in megaface_loader:
|
83 |
-
img, img_path= data[0].to(device), data[1]
|
84 |
-
with torch.no_grad():
|
85 |
-
output = net(img).data.cpu().numpy()
|
86 |
-
|
87 |
-
if do_norm is False:
|
88 |
-
for _, i in enumerate(img_path):
|
89 |
-
abs_path = img_path[i] + '.feat'
|
90 |
-
write_mat(abs_path, output[i])
|
91 |
-
print('extract 1 batch...without feature normalization')
|
92 |
-
else:
|
93 |
-
for _, i in enumerate(img_path):
|
94 |
-
abs_path = img_path[i] + '.feat'
|
95 |
-
feat = output[i]
|
96 |
-
feat = feat / np.sqrt((np.dot(feat, feat)))
|
97 |
-
write_mat(abs_path, feat)
|
98 |
-
print('extract 1 batch...with feature normalization')
|
99 |
-
print('all images have been processed!')
|
100 |
-
|
101 |
-
|
102 |
-
if __name__ == '__main__':
|
103 |
-
parser = argparse.ArgumentParser(description='Testing')
|
104 |
-
parser.add_argument('--model_path', type=str, default='./checkpoints/RES100_RES100_IR_20190423_100728/Iter_333000_net.ckpt', help='The path of trained checkpoints')
|
105 |
-
parser.add_argument('--backbone_net', type=str, default='CBAM_100', help='MobileFace, CBAM_50, CBAM_50_SE, CBAM_100, CBAM_100_SE')
|
106 |
-
parser.add_argument('--facescrub_dir', type=str, default='/media/sda/megaface_test_kit/facescrub_align_112/', help='facescrub data')
|
107 |
-
parser.add_argument('--megaface_dir', type=str, default='/media/sda/megaface_test_kit/megaface_align_112/', help='megaface data')
|
108 |
-
parser.add_argument('--batch_size', type=int, default=1024, help='batch size')
|
109 |
-
parser.add_argument('--feature_dim', type=int, default=512, help='feature dimension')
|
110 |
-
parser.add_argument('--gpus', type=str, default='0,1,2,3', help='gpu list')
|
111 |
-
parser.add_argument("--do_norm", type=int, default=1, help="1 if normalize feature, 0 do nothing(Default case)")
|
112 |
-
args = parser.parse_args()
|
113 |
-
|
114 |
-
extract_feature(args.model_path, args.backbone_net, args.facescrub_dir, args.megaface_dir, args.batch_size, args.gpus, args.do_norm)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/log.log
DELETED
The diff for this file is too large to render.
See raw diff
|
|
face_recognition1/face_feature/loss/__init__.py
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: __init__.py.py
|
6 |
-
@desc:
|
7 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_recognition1/face_feature/loss/agentcenterloss.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# encoding: utf-8
|
3 |
-
'''
|
4 |
-
@author: MingDong
|
5 |
-
@file: agentcenterloss.py
|
6 |
-
@desc: the variety of center loss, which use the class weight as the class center and normalize both the weight and feature,
|
7 |
-
in this way, the cos distance of weight and feature can be used as the supervised signal.
|
8 |
-
It's similar with torch.nn.CosineEmbeddingLoss, x_1 means weight_i, x_2 means feature_i.
|
9 |
-
'''
|
10 |
-
|
11 |
-
import torch
|
12 |
-
import torch.nn as nn
|
13 |
-
import torch.nn.functional as F
|
14 |
-
|
15 |
-
|
16 |
-
class AgentCenterLoss(nn.Module):
|
17 |
-
|
18 |
-
def __init__(self, num_classes, feat_dim, scale):
|
19 |
-
super(AgentCenterLoss, self).__init__()
|
20 |
-
self.num_classes = num_classes
|
21 |
-
self.feat_dim = feat_dim
|
22 |
-
self.scale = scale
|
23 |
-
|
24 |
-
self.centers = nn.Parameter(torch.randn(self.num_classes, self.feat_dim))
|
25 |
-
|
26 |
-
def forward(self, x, labels):
|
27 |
-
'''
|
28 |
-
Parameters:
|
29 |
-
x: input tensor with shape (batch_size, feat_dim)
|
30 |
-
labels: ground truth label with shape (batch_size)
|
31 |
-
Return:
|
32 |
-
loss of centers
|
33 |
-
'''
|
34 |
-
cos_dis = F.linear(F.normalize(x), F.normalize(self.centers)) * self.scale
|
35 |
-
|
36 |
-
one_hot = torch.zeros_like(cos_dis)
|
37 |
-
one_hot.scatter_(1, labels.view(-1, 1), 1.0)
|
38 |
-
|
39 |
-
# loss = 1 - cosine(i)
|
40 |
-
loss = one_hot * self.scale - (one_hot * cos_dis)
|
41 |
-
|
42 |
-
return loss.mean()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|