Unverified Commit df505feb authored by Wenhao Wu's avatar Wenhao Wu Committed by GitHub
Browse files

Fix nonzero warning (#330)

* fix nonzero warning with as_tuple

* fix nonzero warning with as_tuple #320
parent ccd3047a
......@@ -8,7 +8,7 @@ Welcome to MMDetection3D's documentation!
getting_started.md
model_zoo.md
data_preparation.md
.. toctree::
:maxdepth: 2
:caption: Quick Run
......
......@@ -225,7 +225,8 @@ class Anchor3DHead(nn.Module, AnchorTrainMixin):
bg_class_ind = self.num_classes
pos_inds = ((labels >= 0)
& (labels < bg_class_ind)).nonzero().reshape(-1)
& (labels < bg_class_ind)).nonzero(
as_tuple=False).reshape(-1)
num_pos = len(pos_inds)
pos_bbox_pred = bbox_pred[pos_inds]
......
......@@ -519,7 +519,8 @@ class SSD3DHead(VoteHead):
# filter empty boxes and boxes with low score
scores_mask = (obj_scores >= self.test_cfg.score_thr)
nonempty_box_inds = torch.nonzero(nonempty_box_mask).flatten()
nonempty_box_inds = torch.nonzero(
nonempty_box_mask, as_tuple=False).flatten()
nonempty_mask = torch.zeros_like(bbox_classes).scatter(
0, nonempty_box_inds[nms_selected], 1)
selected = (nonempty_mask.bool() & scores_mask.bool())
......
......@@ -277,11 +277,11 @@ class AnchorTrainMixin(object):
neg_inds = sampling_result.neg_inds
else:
pos_inds = torch.nonzero(
anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) > 0
).squeeze(-1).unique()
anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) > 0,
as_tuple=False).squeeze(-1).unique()
neg_inds = torch.nonzero(
anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) ==
0).squeeze(-1).unique()
anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) == 0,
as_tuple=False).squeeze(-1).unique()
if gt_labels is not None:
labels += num_classes
......
......@@ -525,7 +525,8 @@ class H3DBboxHead(nn.Module):
# filter empty boxes and boxes with low score
scores_mask = (obj_scores > self.test_cfg.score_thr)
nonempty_box_inds = torch.nonzero(nonempty_box_mask).flatten()
nonempty_box_inds = torch.nonzero(
nonempty_box_mask, as_tuple=False).flatten()
nonempty_mask = torch.zeros_like(bbox_classes).scatter(
0, nonempty_box_inds[nms_selected], 1)
selected = (nonempty_mask.bool() & scores_mask.bool())
......
......@@ -369,7 +369,7 @@ class PrimitiveHead(nn.Module):
pts_instance_mask[background_mask] = gt_labels_3d.shape[0]
instance_flag = torch.nonzero(
pts_semantic_mask != self.num_classes).squeeze(1)
pts_semantic_mask != self.num_classes, as_tuple=False).squeeze(1)
instance_labels = pts_instance_mask[instance_flag].unique()
with_yaw = gt_bboxes_3d.with_yaw
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment