Skip to content

Commit

Permalink
Merge pull request #220 from yuedongli1/master
Browse files Browse the repository at this point in the history
modify _clip_coords to in-place operation
  • Loading branch information
CaitinZhao authored Oct 25, 2023
2 parents d1d16b3 + 2f398c7 commit ebfd2bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions mindyolo/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ def scale_coords(img1_shape, coords, img0_shape, ratio=None, pad=None):

def _clip_coords(boxes, img_shape):
# Clip bounding xyxy bounding boxes to image shape (height, width)
boxes[:, 0].clip(0, img_shape[1]) # x1
boxes[:, 1].clip(0, img_shape[0]) # y1
boxes[:, 2].clip(0, img_shape[1]) # x2
boxes[:, 3].clip(0, img_shape[0]) # y2
boxes[..., [0, 2]] = boxes[..., [0, 2]].clip(0, img_shape[1]) # x1, x2
boxes[..., [1, 3]] = boxes[..., [1, 3]].clip(0, img_shape[0]) # y1, y2
return boxes


Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_detect(

# Predictions
predn = np.copy(pred)
scale_coords(
predn[:, :4] = scale_coords(
imgs[si].shape[1:], predn[:, :4], ori_shape[si], ratio=hw_scale[si], pad=pad[si]
) # native-space pred

Expand Down

0 comments on commit ebfd2bc

Please sign in to comment.