Skip to content

Commit

Permalink
numpy throwing deprecation warning for creating ndarray from nested s…
Browse files Browse the repository at this point in the history
…equences (#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 <[email protected]>
  • Loading branch information
timesler and MarkhamLee authored Apr 6, 2023
1 parent 78ec3ec commit fa70227
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions models/mtcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ def detect(self, img, landmarks=False):
boxes.append(box[:, :4])
probs.append(box[:, 4])
points.append(point)
boxes = np.array(boxes)
probs = np.array(probs)
points = np.array(points)
boxes = np.array(boxes, dtype=object)
probs = np.array(probs, dtype=object)
points = np.array(points, dtype=object)

if (
not isinstance(img, (list, tuple)) and
Expand Down
2 changes: 1 addition & 1 deletion models/utils/detect_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def detect_face(imgs, minsize, pnet, rnet, onet, threshold, factor, device):
batch_boxes.append(boxes[b_i_inds].copy())
batch_points.append(points[b_i_inds].copy())

batch_boxes, batch_points = np.array(batch_boxes), np.array(batch_points)
batch_boxes, batch_points = np.array(batch_boxes, dtype=object), np.array(batch_points, dtype=object)

return batch_boxes, batch_points

Expand Down

0 comments on commit fa70227

Please sign in to comment.