Skip to content

Commit

Permalink
Merge pull request #25 from huhongsun/rc41.x
Browse files Browse the repository at this point in the history
repair nms_rotated bug
  • Loading branch information
momo609 authored Jun 17, 2024
2 parents 38da280 + c38593d commit 128f29a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion mmcv/ops/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def nms_rotated(dets: Tensor,
flip_mat[-1] = -1
dets_cw = dets * flip_mat
else:
dets_cw = dets
dets_cw = dets.clone()
multi_label = labels is not None
if labels is None:
input_labels = scores.new_empty(0, dtype=torch.int)
Expand All @@ -462,6 +462,8 @@ def nms_rotated(dets: Tensor,
order = scores.new_empty(0, dtype=torch.long)
if dets.device.type == 'npu':
coefficient = 57.29578 # 180 / PI
dets_cw = dets_cw.float()
scores = scores.float()
for i in range(dets.size()[0]):
dets_cw[i][4] *= coefficient # radians to angle
keep_inds = ext_module.nms_rotated(dets_cw, scores, order, dets_cw,
Expand Down
5 changes: 2 additions & 3 deletions mmcv/ops/points_in_polygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def points_in_polygons(points: Tensor, polygons: Tensor) -> Tensor:
polygons (torch.Tensor): It has shape (M, 8), indicating
(x1, y1, x2, y2, x3, y3, x4, y4). M means the number of
ground truth polygons.
constraints: The absolute value of input range from e-10 to
e10 on NPU.
constraints: The number of significant digits for the input-arguments
are between -10 and 10 when running on Ascend device.
Returns:
torch.Tensor: Return the result with the shape of (B, M),
Expand Down

0 comments on commit 128f29a

Please sign in to comment.