@@ -60,7 +60,7 @@ def detect_face(imgs, minsize, pnet, rnet, onet, threshold, factor, device):
60
60
total_boxes = np .transpose (np .vstack ([qq1 , qq2 , qq3 , qq4 , total_boxes [:, 4 ]]))
61
61
total_boxes = rerec (total_boxes )
62
62
total_boxes [:, 0 :4 ] = np .fix (total_boxes [:, 0 :4 ]).astype (np .int32 )
63
- dy , edy , dx , edx , y , ey , x , ex , tmpw , tmph = pad (total_boxes , w , h )
63
+ y , ey , x , ex = pad (total_boxes , w , h )
64
64
65
65
numbox = total_boxes .shape [0 ]
66
66
if numbox > 0 :
@@ -92,7 +92,7 @@ def detect_face(imgs, minsize, pnet, rnet, onet, threshold, factor, device):
92
92
if numbox > 0 :
93
93
# third stage
94
94
total_boxes = np .fix (total_boxes ).astype (np .int32 )
95
- dy , edy , dx , edx , y , ey , x , ex , tmpw , tmph = pad (total_boxes .copy (), w , h )
95
+ y , ey , x , ex = pad (total_boxes .copy (), w , h )
96
96
im_data = []
97
97
for k in range (0 , numbox ):
98
98
if ey [k ] > (y [k ] - 1 ) and ex [k ] > (x [k ] - 1 ):
@@ -197,37 +197,17 @@ def nms(boxes, threshold, method):
197
197
198
198
199
199
def pad (total_boxes , w , h ):
200
- tmpw = (total_boxes [:, 2 ] - total_boxes [:, 0 ] + 1 ).astype (np .int32 )
201
- tmph = (total_boxes [:, 3 ] - total_boxes [:, 1 ] + 1 ).astype (np .int32 )
202
- numbox = total_boxes .shape [0 ]
203
-
204
- dx = np .ones ((numbox ), dtype = np .int32 )
205
- dy = np .ones ((numbox ), dtype = np .int32 )
206
- edx = tmpw .copy ().astype (np .int32 )
207
- edy = tmph .copy ().astype (np .int32 )
208
-
209
200
x = total_boxes [:, 0 ].copy ().astype (np .int32 )
210
201
y = total_boxes [:, 1 ].copy ().astype (np .int32 )
211
202
ex = total_boxes [:, 2 ].copy ().astype (np .int32 )
212
203
ey = total_boxes [:, 3 ].copy ().astype (np .int32 )
213
204
214
- tmp = np .where (ex > w )
215
- edx .flat [tmp ] = np .expand_dims (- ex [tmp ] + w + tmpw [tmp ], 1 )
216
- ex [tmp ] = w
217
-
218
- tmp = np .where (ey > h )
219
- edy .flat [tmp ] = np .expand_dims (- ey [tmp ] + h + tmph [tmp ], 1 )
220
- ey [tmp ] = h
221
-
222
- tmp = np .where (x < 1 )
223
- dx .flat [tmp ] = np .expand_dims (2 - x [tmp ], 1 )
224
- x [tmp ] = 1
225
-
226
- tmp = np .where (y < 1 )
227
- dy .flat [tmp ] = np .expand_dims (2 - y [tmp ], 1 )
228
- y [tmp ] = 1
205
+ x [np .where (x < 1 )] = 1
206
+ y [np .where (y < 1 )] = 1
207
+ ex [np .where (ex > w )] = w
208
+ ey [np .where (ey > h )] = h
229
209
230
- return dy , edy , dx , edx , y , ey , x , ex , tmpw , tmph
210
+ return y , ey , x , ex
231
211
232
212
233
213
def rerec (bboxA ):
0 commit comments