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
MMCV
Commits
af861bf9
Unverified
Commit
af861bf9
authored
May 27, 2022
by
gy77
Committed by
GitHub
May 27, 2022
Browse files
Add type hints in iou3d.py (#1989)
* add type hints in iou3d.py * fix lint
parent
bb4c65d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
mmcv/ops/iou3d.py
mmcv/ops/iou3d.py
+13
-6
No files found.
mmcv/ops/iou3d.py
View file @
af861bf9
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import
warnings
import
warnings
from
typing
import
Optional
import
torch
import
torch
from
torch
import
Tensor
from
..utils
import
ext_loader
from
..utils
import
ext_loader
...
@@ -11,7 +13,7 @@ ext_module = ext_loader.load_ext('_ext', [
...
@@ -11,7 +13,7 @@ ext_module = ext_loader.load_ext('_ext', [
])
])
def
boxes_iou3d
(
boxes_a
,
boxes_b
)
:
def
boxes_iou3d
(
boxes_a
:
Tensor
,
boxes_b
:
Tensor
)
->
Tensor
:
"""Calculate boxes 3D IoU.
"""Calculate boxes 3D IoU.
Args:
Args:
...
@@ -30,7 +32,7 @@ def boxes_iou3d(boxes_a, boxes_b):
...
@@ -30,7 +32,7 @@ def boxes_iou3d(boxes_a, boxes_b):
return
ans_iou
return
ans_iou
def
nms3d
(
boxes
,
scores
,
iou_threshold
)
:
def
nms3d
(
boxes
:
Tensor
,
scores
:
Tensor
,
iou_threshold
:
float
)
->
Tensor
:
"""3D NMS function GPU implementation (for BEV boxes).
"""3D NMS function GPU implementation (for BEV boxes).
Args:
Args:
...
@@ -54,7 +56,8 @@ def nms3d(boxes, scores, iou_threshold):
...
@@ -54,7 +56,8 @@ def nms3d(boxes, scores, iou_threshold):
return
keep
return
keep
def
nms3d_normal
(
boxes
,
scores
,
iou_threshold
):
def
nms3d_normal
(
boxes
:
Tensor
,
scores
:
Tensor
,
iou_threshold
:
float
)
->
Tensor
:
"""Normal 3D NMS function GPU implementation. The overlap of two boxes for
"""Normal 3D NMS function GPU implementation. The overlap of two boxes for
IoU calculation is defined as the exact overlapping area of the two boxes
IoU calculation is defined as the exact overlapping area of the two boxes
WITH their yaw angle set to 0.
WITH their yaw angle set to 0.
...
@@ -79,7 +82,7 @@ def nms3d_normal(boxes, scores, iou_threshold):
...
@@ -79,7 +82,7 @@ def nms3d_normal(boxes, scores, iou_threshold):
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
return
order
[
keep
[:
num_out
].
cuda
(
boxes
.
device
)].
contiguous
()
def
_xyxyr2xywhr
(
boxes
)
:
def
_xyxyr2xywhr
(
boxes
:
Tensor
)
->
Tensor
:
"""Convert [x1, y1, x2, y2, heading] box to [x, y, dx, dy, heading] box.
"""Convert [x1, y1, x2, y2, heading] box to [x, y, dx, dy, heading] box.
Args:
Args:
...
@@ -119,7 +122,11 @@ def boxes_iou_bev(boxes_a, boxes_b):
...
@@ -119,7 +122,11 @@ def boxes_iou_bev(boxes_a, boxes_b):
return
box_iou_rotated
(
_xyxyr2xywhr
(
boxes_a
),
_xyxyr2xywhr
(
boxes_b
))
return
box_iou_rotated
(
_xyxyr2xywhr
(
boxes_a
),
_xyxyr2xywhr
(
boxes_b
))
def
nms_bev
(
boxes
,
scores
,
thresh
,
pre_max_size
=
None
,
post_max_size
=
None
):
def
nms_bev
(
boxes
:
Tensor
,
scores
:
Tensor
,
thresh
:
float
,
pre_max_size
:
Optional
[
int
]
=
None
,
post_max_size
:
Optional
[
int
]
=
None
)
->
Tensor
:
"""NMS function GPU implementation (for BEV boxes).
"""NMS function GPU implementation (for BEV boxes).
The overlap of two
The overlap of two
...
@@ -159,7 +166,7 @@ def nms_bev(boxes, scores, thresh, pre_max_size=None, post_max_size=None):
...
@@ -159,7 +166,7 @@ def nms_bev(boxes, scores, thresh, pre_max_size=None, post_max_size=None):
return
keep
return
keep
def
nms_normal_bev
(
boxes
,
scores
,
thresh
)
:
def
nms_normal_bev
(
boxes
:
Tensor
,
scores
:
Tensor
,
thresh
:
float
)
->
Tensor
:
"""Normal NMS function GPU implementation (for BEV boxes).
"""Normal NMS function GPU implementation (for BEV boxes).
The overlap of
The overlap of
...
...
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