Skip to content

Commit

Permalink
Add deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
yezhen17 committed Aug 11, 2021
1 parent 8f0669d commit aacbc11
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
13 changes: 13 additions & 0 deletions mmdet3d/core/bbox/structures/base_box3d.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import torch
import warnings
from abc import abstractmethod

from mmdet3d.ops import points_in_boxes_all, points_in_boxes_part
Expand Down Expand Up @@ -565,3 +566,15 @@ def points_in_boxes_all(self, points, boxes_override=None):
box_idxs_of_pts = points_in_boxes_all(points_clone, boxes)

return box_idxs_of_pts.squeeze(0)

def points_in_boxes(self, points, boxes_override=None):
warnings.warn('DeprecationWarning: points_in_boxes is a '
'deprecated method, please consider using '
'points_in_boxes_part.')
return self.points_in_boxes_part(points, boxes_override)

def points_in_boxes_batch(self, points, boxes_override=None):
warnings.warn('DeprecationWarning: points_in_boxes_batch is a '
'deprecated method, please consider using '
'points_in_boxes_all.')
return self.points_in_boxes_all(points, boxes_override)
12 changes: 6 additions & 6 deletions mmdet3d/models/detectors/imvotenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,21 @@ def __init__(self,

if self.with_img_backbone:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.img_backbone.init_cfg = dict(
type='Pretrained', checkpoint=img_pretrained)
if self.with_img_roi_head:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.img_roi_head.init_cfg = dict(
type='Pretrained', checkpoint=img_pretrained)

if self.with_pts_backbone:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.pts_backbone.init_cfg = dict(
type='Pretrained', checkpoint=pts_pretrained)

Expand Down
12 changes: 6 additions & 6 deletions mmdet3d/models/detectors/mvx_two_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ def __init__(self,

if self.with_img_backbone:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.img_backbone.init_cfg = dict(
type='Pretrained', checkpoint=img_pretrained)
if self.with_img_roi_head:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.img_roi_head.init_cfg = dict(
type='Pretrained', checkpoint=img_pretrained)

if self.with_pts_backbone:
if img_pretrained is not None:
warnings.warn('DeprecationWarning: pretrained is a deprecated \
key, please consider using init_cfg')
warnings.warn('DeprecationWarning: pretrained is a deprecated '
'key, please consider using init_cfg.')
self.pts_backbone.init_cfg = dict(
type='Pretrained', checkpoint=pts_pretrained)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_utils/test_box3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,9 @@ def test_points_in_boxes():
assert point_indices.shape == torch.Size([23, 6])
assert (point_indices == expected_point_indices).all()

point_indices = cam_boxes.points_in_boxes_batch(cam_pts)
assert (point_indices == expected_point_indices).all()

point_indices = cam_boxes.points_in_boxes_part(cam_pts)
expected_point_indices = torch.tensor([
0, 0, 0, 0, 0, 1, -1, -1, -1, -1, -1, -1, 3, -1, -1, 2, 3, 3, 2, 2, 3,
Expand All @@ -1762,3 +1765,6 @@ def test_points_in_boxes():
dtype=torch.int32).cuda()
assert point_indices.shape == torch.Size([23])
assert (point_indices == expected_point_indices).all()

point_indices = cam_boxes.points_in_boxes(cam_pts)
assert (point_indices == expected_point_indices).all()

0 comments on commit aacbc11

Please sign in to comment.