Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
f6a7d78c
Unverified
Commit
f6a7d78c
authored
Aug 20, 2020
by
Wenwei Zhang
Committed by
GitHub
Aug 20, 2020
Browse files
Fix (torch.nonzero): Fix warning of torch.nonzero and bug of nms_iou (#70)
parent
3ba50ca5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
10 deletions
+16
-10
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
+3
-2
mmdet3d/core/post_processing/box3d_nms.py
mmdet3d/core/post_processing/box3d_nms.py
+2
-1
mmdet3d/models/dense_heads/free_anchor3d_head.py
mmdet3d/models/dense_heads/free_anchor3d_head.py
+1
-1
mmdet3d/models/dense_heads/vote_head.py
mmdet3d/models/dense_heads/vote_head.py
+8
-4
mmdet3d/ops/iou3d/iou3d_utils.py
mmdet3d/ops/iou3d/iou3d_utils.py
+2
-2
No files found.
mmdet3d/core/bbox/samplers/iou_neg_piecewise_sampler.py
View file @
f6a7d78c
...
@@ -55,7 +55,7 @@ class IoUNegPiecewiseSampler(RandomSampler):
...
@@ -55,7 +55,7 @@ class IoUNegPiecewiseSampler(RandomSampler):
def
_sample_neg
(
self
,
assign_result
,
num_expected
,
**
kwargs
):
def
_sample_neg
(
self
,
assign_result
,
num_expected
,
**
kwargs
):
"""Randomly sample some negative samples."""
"""Randomly sample some negative samples."""
neg_inds
=
torch
.
nonzero
(
assign_result
.
gt_inds
==
0
)
neg_inds
=
torch
.
nonzero
(
assign_result
.
gt_inds
==
0
,
as_tuple
=
False
)
if
neg_inds
.
numel
()
!=
0
:
if
neg_inds
.
numel
()
!=
0
:
neg_inds
=
neg_inds
.
squeeze
(
1
)
neg_inds
=
neg_inds
.
squeeze
(
1
)
if
len
(
neg_inds
)
<=
num_expected
:
if
len
(
neg_inds
)
<=
num_expected
:
...
@@ -80,7 +80,8 @@ class IoUNegPiecewiseSampler(RandomSampler):
...
@@ -80,7 +80,8 @@ class IoUNegPiecewiseSampler(RandomSampler):
max_iou_thr
=
self
.
neg_iou_thr
[
piece_inds
]
max_iou_thr
=
self
.
neg_iou_thr
[
piece_inds
]
piece_neg_inds
=
torch
.
nonzero
(
piece_neg_inds
=
torch
.
nonzero
(
(
max_overlaps
>=
min_iou_thr
)
(
max_overlaps
>=
min_iou_thr
)
&
(
max_overlaps
<
max_iou_thr
)).
view
(
-
1
)
&
(
max_overlaps
<
max_iou_thr
),
as_tuple
=
False
).
view
(
-
1
)
if
len
(
piece_neg_inds
)
<
piece_expected_num
:
if
len
(
piece_neg_inds
)
<
piece_expected_num
:
neg_inds_choice
=
torch
.
cat
(
neg_inds_choice
=
torch
.
cat
(
...
...
mmdet3d/core/post_processing/box3d_nms.py
View file @
f6a7d78c
...
@@ -129,7 +129,8 @@ def aligned_3d_nms(boxes, scores, classes, thresh):
...
@@ -129,7 +129,8 @@ def aligned_3d_nms(boxes, scores, classes, thresh):
inter
=
inter_l
*
inter_w
*
inter_h
inter
=
inter_l
*
inter_w
*
inter_h
iou
=
inter
/
(
area
[
i
]
+
area
[
score_sorted
[:
last
-
1
]]
-
inter
)
iou
=
inter
/
(
area
[
i
]
+
area
[
score_sorted
[:
last
-
1
]]
-
inter
)
iou
=
iou
*
(
classes1
==
classes2
).
float
()
iou
=
iou
*
(
classes1
==
classes2
).
float
()
score_sorted
=
score_sorted
[
torch
.
nonzero
(
iou
<=
thresh
).
flatten
()]
score_sorted
=
score_sorted
[
torch
.
nonzero
(
iou
<=
thresh
,
as_tuple
=
False
).
flatten
()]
indices
=
boxes
.
new_tensor
(
pick
,
dtype
=
torch
.
long
)
indices
=
boxes
.
new_tensor
(
pick
,
dtype
=
torch
.
long
)
return
indices
return
indices
mmdet3d/models/dense_heads/free_anchor3d_head.py
View file @
f6a7d78c
...
@@ -140,7 +140,7 @@ class FreeAnchor3DHead(Anchor3DHead):
...
@@ -140,7 +140,7 @@ class FreeAnchor3DHead(Anchor3DHead):
box_cls_prob
=
torch
.
sparse
.
sum
(
box_cls_prob
=
torch
.
sparse
.
sum
(
object_cls_box_prob
,
dim
=
0
).
to_dense
()
object_cls_box_prob
,
dim
=
0
).
to_dense
()
indices
=
torch
.
nonzero
(
box_cls_prob
).
t_
()
indices
=
torch
.
nonzero
(
box_cls_prob
,
as_tuple
=
False
).
t_
()
if
indices
.
numel
()
==
0
:
if
indices
.
numel
()
==
0
:
image_box_prob
=
torch
.
zeros
(
image_box_prob
=
torch
.
zeros
(
anchors_
.
size
(
0
),
anchors_
.
size
(
0
),
...
...
mmdet3d/models/dense_heads/vote_head.py
View file @
f6a7d78c
...
@@ -409,7 +409,8 @@ class VoteHead(nn.Module):
...
@@ -409,7 +409,8 @@ class VoteHead(nn.Module):
box_indices_all
=
gt_bboxes_3d
.
points_in_boxes
(
points
)
box_indices_all
=
gt_bboxes_3d
.
points_in_boxes
(
points
)
for
i
in
range
(
gt_labels_3d
.
shape
[
0
]):
for
i
in
range
(
gt_labels_3d
.
shape
[
0
]):
box_indices
=
box_indices_all
[:,
i
]
box_indices
=
box_indices_all
[:,
i
]
indices
=
torch
.
nonzero
(
box_indices
).
squeeze
(
-
1
)
indices
=
torch
.
nonzero
(
box_indices
,
as_tuple
=
False
).
squeeze
(
-
1
)
selected_points
=
points
[
indices
]
selected_points
=
points
[
indices
]
vote_target_masks
[
indices
]
=
1
vote_target_masks
[
indices
]
=
1
vote_targets_tmp
=
vote_targets
[
indices
]
vote_targets_tmp
=
vote_targets
[
indices
]
...
@@ -418,7 +419,8 @@ class VoteHead(nn.Module):
...
@@ -418,7 +419,8 @@ class VoteHead(nn.Module):
for
j
in
range
(
self
.
gt_per_seed
):
for
j
in
range
(
self
.
gt_per_seed
):
column_indices
=
torch
.
nonzero
(
column_indices
=
torch
.
nonzero
(
vote_target_idx
[
indices
]
==
j
).
squeeze
(
-
1
)
vote_target_idx
[
indices
]
==
j
,
as_tuple
=
False
).
squeeze
(
-
1
)
vote_targets_tmp
[
column_indices
,
vote_targets_tmp
[
column_indices
,
int
(
j
*
3
):
int
(
j
*
3
+
int
(
j
*
3
):
int
(
j
*
3
+
3
)]
=
votes
[
column_indices
]
3
)]
=
votes
[
column_indices
]
...
@@ -435,7 +437,8 @@ class VoteHead(nn.Module):
...
@@ -435,7 +437,8 @@ class VoteHead(nn.Module):
dtype
=
torch
.
long
)
dtype
=
torch
.
long
)
for
i
in
torch
.
unique
(
pts_instance_mask
):
for
i
in
torch
.
unique
(
pts_instance_mask
):
indices
=
torch
.
nonzero
(
pts_instance_mask
==
i
).
squeeze
(
-
1
)
indices
=
torch
.
nonzero
(
pts_instance_mask
==
i
,
as_tuple
=
False
).
squeeze
(
-
1
)
if
pts_semantic_mask
[
indices
[
0
]]
<
self
.
num_classes
:
if
pts_semantic_mask
[
indices
[
0
]]
<
self
.
num_classes
:
selected_points
=
points
[
indices
,
:
3
]
selected_points
=
points
[
indices
,
:
3
]
center
=
0.5
*
(
center
=
0.5
*
(
...
@@ -558,7 +561,8 @@ class VoteHead(nn.Module):
...
@@ -558,7 +561,8 @@ class VoteHead(nn.Module):
# filter empty boxes and boxes with low score
# filter empty boxes and boxes with low score
scores_mask
=
(
obj_scores
>
self
.
test_cfg
.
score_thr
)
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
(
nonempty_mask
=
torch
.
zeros_like
(
bbox_classes
).
scatter
(
0
,
nonempty_box_inds
[
nms_selected
],
1
)
0
,
nonempty_box_inds
[
nms_selected
],
1
)
selected
=
(
nonempty_mask
.
bool
()
&
scores_mask
.
bool
())
selected
=
(
nonempty_mask
.
bool
()
&
scores_mask
.
bool
())
...
...
mmdet3d/ops/iou3d/iou3d_utils.py
View file @
f6a7d78c
...
@@ -37,7 +37,7 @@ def nms_gpu(boxes, scores, thresh):
...
@@ -37,7 +37,7 @@ def nms_gpu(boxes, scores, thresh):
boxes
=
boxes
[
order
].
contiguous
()
boxes
=
boxes
[
order
].
contiguous
()
keep
=
boxes
.
new_
zeros
(
boxes
.
size
(
0
))
keep
=
torch
.
zeros
(
boxes
.
size
(
0
)
,
dtype
=
torch
.
long
)
num_out
=
iou3d_cuda
.
nms_gpu
(
boxes
,
keep
,
thresh
,
boxes
.
device
.
index
)
num_out
=
iou3d_cuda
.
nms_gpu
(
boxes
,
keep
,
thresh
,
boxes
.
device
.
index
)
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
...
@@ -57,7 +57,7 @@ def nms_normal_gpu(boxes, scores, thresh):
...
@@ -57,7 +57,7 @@ def nms_normal_gpu(boxes, scores, thresh):
boxes
=
boxes
[
order
].
contiguous
()
boxes
=
boxes
[
order
].
contiguous
()
keep
=
boxes
.
new_
zeros
(
boxes
.
size
(
0
))
keep
=
torch
.
zeros
(
boxes
.
size
(
0
)
,
dtype
=
torch
.
long
)
num_out
=
iou3d_cuda
.
nms_normal_gpu
(
boxes
,
keep
,
thresh
,
num_out
=
iou3d_cuda
.
nms_normal_gpu
(
boxes
,
keep
,
thresh
,
boxes
.
device
.
index
)
boxes
.
device
.
index
)
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment