Skip to content

Commit fa70227

Browse files
timeslerMarkhamLee
andauthored
numpy throwing deprecation warning for creating ndarray from nested sequences (#196) (#207)
Numpy is throwing deprecation warnings for creating arrays from nested sequences on line 183 of detect_face.py and on lines 339, 340, 341 of mtcnn.py when running the example training script. The fix is to pass 'dtype=object' as a parameter when creating the ndarray. E.g., on line 339 of mtcnn.py np.array(boxes) becomes np.array(boxes, dtype=object) Co-authored-by: Markham Lee <markhamlee@outlook.com>
1 parent 78ec3ec commit fa70227

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

models/mtcnn.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ def detect(self, img, landmarks=False):
336336
boxes.append(box[:, :4])
337337
probs.append(box[:, 4])
338338
points.append(point)
339-
boxes = np.array(boxes)
340-
probs = np.array(probs)
341-
points = np.array(points)
339+
boxes = np.array(boxes, dtype=object)
340+
probs = np.array(probs, dtype=object)
341+
points = np.array(points, dtype=object)
342342

343343
if (
344344
not isinstance(img, (list, tuple)) and

models/utils/detect_face.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def detect_face(imgs, minsize, pnet, rnet, onet, threshold, factor, device):
180180
batch_boxes.append(boxes[b_i_inds].copy())
181181
batch_points.append(points[b_i_inds].copy())
182182

183-
batch_boxes, batch_points = np.array(batch_boxes), np.array(batch_points)
183+
batch_boxes, batch_points = np.array(batch_boxes, dtype=object), np.array(batch_points, dtype=object)
184184

185185
return batch_boxes, batch_points
186186

0 commit comments

Comments
 (0)