Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG FIX] Remove unnecessary padding during NMS #2584

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions mmdeploy/mmcv/ops/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ def _multiclass_nms_single(boxes: Tensor,
dets = torch.cat([boxes, scores], dim=2)
labels = cls_inds.unsqueeze(0)

# pad
dets = torch.cat((dets, dets.new_zeros((1, 1, 5))), 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this padding is useful for case when selected_indices is zero shaped tensor.

labels = torch.cat((labels, labels.new_zeros((1, 1))), 1)

# topk or sort
is_use_topk = keep_top_k > 0 and \
(torch.onnx.is_in_onnx_export() or keep_top_k < dets.shape[1])
Expand All @@ -369,7 +365,7 @@ def _multiclass_nms_single(boxes: Tensor,
if pre_top_k > 0:
bbox_index = pre_topk_inds[None, box_inds]
if keep_top_k > 0:
bbox_index = bbox_index[:, topk_inds[:-1]]
bbox_index = bbox_index[:, topk_inds]
return dets, labels, bbox_index
else:
return dets, labels
Expand Down
Loading