Add type hints in bbox.py and box_iou_rotated.py (#1981)

* Add type hints in bbox.py

* Add type hints in box_iou_rotated.py

* Update ball_query.py

* Revert "Add type hints in bbox.py"

This reverts commit 102566488e3aa9328b1c6e1159e2699d40f9f9f5.

* Update bbox.py

* Revert "Update bbox.py"

This reverts commit d34b2c6ed54ba024b9674c948493001a8b4ff864.

* Update bbox.py
This commit is contained in:
Range King 2022-05-27 10:21:48 +08:00 committed by GitHub
parent 1e922b84ee
commit bb4c65d8ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

View File

@ -18,7 +18,7 @@ class BallQuery(Function):
min_radius (float): minimum radius of the balls.
max_radius (float): maximum radius of the balls.
sample_num (int): maximum number of features in the balls.
xyz (Tensor): (B, N, 3) xyz coordinates of the features.
xyz (torch.Tensor): (B, N, 3) xyz coordinates of the features.
center_xyz (torch.Tensor): (B, npoint, 3) centers of the ball
query.

View File

@ -6,7 +6,11 @@ from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['bbox_overlaps'])
def _bbox_overlaps_cpu(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
def _bbox_overlaps_cpu(bboxes1: torch.Tensor,
bboxes2: torch.Tensor,
mode: str = 'iou',
aligned: bool = False,
offset: int = 0) -> torch.Tensor:
assert mode in ['iou', 'iof']
if aligned:
@ -43,7 +47,11 @@ def _bbox_overlaps_cpu(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
return ious
def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
def bbox_overlaps(bboxes1: torch.Tensor,
bboxes2: torch.Tensor,
mode: str = 'iou',
aligned: bool = False,
offset: int = 0) -> torch.Tensor:
"""Calculate overlap between two set of bboxes.
If ``aligned`` is ``False``, then calculate the ious between each bbox

View File

@ -1,14 +1,16 @@
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..utils import ext_loader
ext_module = ext_loader.load_ext('_ext', ['box_iou_rotated'])
def box_iou_rotated(bboxes1,
bboxes2,
mode='iou',
aligned=False,
clockwise=True):
def box_iou_rotated(bboxes1: torch.Tensor,
bboxes2: torch.Tensor,
mode: str = 'iou',
aligned: bool = False,
clockwise: bool = True) -> torch.Tensor:
"""Return intersection-over-union (Jaccard index) of boxes.
Both sets of boxes are expected to be in