Commit 1a47acdd authored by Jingwei Zhang's avatar Jingwei Zhang Committed by ZwwWayne
Browse files

[CI] Add github action CI && refactor `tests/utils/` (#2012)

* update github action ci

* install torch in ci

* fix ci on win

* add __init__ in tests/utils

* add mmdet3d/testing for modeule importing in UT in win

* fix diff path sep on UT

* reduce RAM in voxel_generator

* reduce RAM in anchor_generator

* remove print in UT

* fix lint

* fix pvrcnn ut

* fix lint

* reduce channels in second_fpn
parent 139c6f0c
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestFCAF3d(unittest.TestCase): class TestFCAF3d(unittest.TestCase):
...@@ -19,12 +19,12 @@ class TestFCAF3d(unittest.TestCase): ...@@ -19,12 +19,12 @@ class TestFCAF3d(unittest.TestCase):
import mmdet3d.models import mmdet3d.models
assert hasattr(mmdet3d.models, 'MinkSingleStage3DDetector') assert hasattr(mmdet3d.models, 'MinkSingleStage3DDetector')
DefaultScope.get_instance('test_fcaf3d', scope_name='mmdet3d') DefaultScope.get_instance('test_fcaf3d', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
fcaf3d_net_cfg = _get_detector_cfg( fcaf3d_net_cfg = get_detector_cfg(
'fcaf3d/fcaf3d_2xb8_scannet-3d-18class.py') 'fcaf3d/fcaf3d_2xb8_scannet-3d-18class.py')
model = MODELS.build(fcaf3d_net_cfg) model = MODELS.build(fcaf3d_net_cfg)
num_gt_instance = 3 num_gt_instance = 3
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
num_gt_instance=num_gt_instance, num_gt_instance=num_gt_instance,
num_classes=1, num_classes=1,
points_feat_dim=6, points_feat_dim=6,
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestGroupfree3d(unittest.TestCase): class TestGroupfree3d(unittest.TestCase):
...@@ -15,12 +15,12 @@ class TestGroupfree3d(unittest.TestCase): ...@@ -15,12 +15,12 @@ class TestGroupfree3d(unittest.TestCase):
assert hasattr(mmdet3d.models, 'GroupFree3DNet') assert hasattr(mmdet3d.models, 'GroupFree3DNet')
DefaultScope.get_instance('test_groupfree3d', scope_name='mmdet3d') DefaultScope.get_instance('test_groupfree3d', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
voxel_net_cfg = _get_detector_cfg( voxel_net_cfg = get_detector_cfg(
'groupfree3d/groupfree3d_head-L6-O256_4xb8_scannet-seg.py') 'groupfree3d/groupfree3d_head-L6-O256_4xb8_scannet-seg.py')
model = MODELS.build(voxel_net_cfg) model = MODELS.build(voxel_net_cfg)
num_gt_instance = 5 num_gt_instance = 5
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
num_gt_instance=num_gt_instance, num_gt_instance=num_gt_instance,
points_feat_dim=3, points_feat_dim=3,
with_pts_semantic_mask=True, with_pts_semantic_mask=True,
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestH3D(unittest.TestCase): class TestH3D(unittest.TestCase):
...@@ -15,11 +15,11 @@ class TestH3D(unittest.TestCase): ...@@ -15,11 +15,11 @@ class TestH3D(unittest.TestCase):
assert hasattr(mmdet3d.models, 'H3DNet') assert hasattr(mmdet3d.models, 'H3DNet')
DefaultScope.get_instance('test_H3DNet', scope_name='mmdet3d') DefaultScope.get_instance('test_H3DNet', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
voxel_net_cfg = _get_detector_cfg('h3dnet/h3dnet_8xb3_scannet-seg.py') voxel_net_cfg = get_detector_cfg('h3dnet/h3dnet_8xb3_scannet-seg.py')
model = MODELS.build(voxel_net_cfg) model = MODELS.build(voxel_net_cfg)
num_gt_instance = 5 num_gt_instance = 5
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
num_gt_instance=num_gt_instance, num_gt_instance=num_gt_instance,
points_feat_dim=4, points_feat_dim=4,
bboxes_3d_type='depth', bboxes_3d_type='depth',
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestImvoteNet(unittest.TestCase): class TestImvoteNet(unittest.TestCase):
...@@ -15,12 +15,12 @@ class TestImvoteNet(unittest.TestCase): ...@@ -15,12 +15,12 @@ class TestImvoteNet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'ImVoteNet') assert hasattr(mmdet3d.models, 'ImVoteNet')
DefaultScope.get_instance('test_imvotenet_img', scope_name='mmdet3d') DefaultScope.get_instance('test_imvotenet_img', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
votenet_net_cfg = _get_detector_cfg( votenet_net_cfg = get_detector_cfg(
'imvotenet/imvotenet_faster-rcnn-r50_fpn_4xb2_sunrgbd-3d.py') 'imvotenet/imvotenet_faster-rcnn-r50_fpn_4xb2_sunrgbd-3d.py')
model = MODELS.build(votenet_net_cfg) model = MODELS.build(votenet_net_cfg)
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
with_points=False, with_img=True, img_size=128) with_points=False, with_img=True, img_size=128)
if torch.cuda.is_available(): if torch.cuda.is_available():
...@@ -49,12 +49,12 @@ class TestImvoteNet(unittest.TestCase): ...@@ -49,12 +49,12 @@ class TestImvoteNet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'ImVoteNet') assert hasattr(mmdet3d.models, 'ImVoteNet')
DefaultScope.get_instance('test_imvotenet', scope_name='mmdet3d') DefaultScope.get_instance('test_imvotenet', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
votenet_net_cfg = _get_detector_cfg( votenet_net_cfg = get_detector_cfg(
'imvotenet/imvotenet_stage2_8xb16_sunrgbd-3d.py') 'imvotenet/imvotenet_stage2_8xb16_sunrgbd-3d.py')
model = MODELS.build(votenet_net_cfg) model = MODELS.build(votenet_net_cfg)
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
with_points=True, with_points=True,
with_img=True, with_img=True,
img_size=128, img_size=128,
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestImVoxelNet(unittest.TestCase): class TestImVoxelNet(unittest.TestCase):
...@@ -15,12 +15,12 @@ class TestImVoxelNet(unittest.TestCase): ...@@ -15,12 +15,12 @@ class TestImVoxelNet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'ImVoxelNet') assert hasattr(mmdet3d.models, 'ImVoxelNet')
DefaultScope.get_instance('test_ImVoxelNet', scope_name='mmdet3d') DefaultScope.get_instance('test_ImVoxelNet', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
imvoxel_net_cfg = _get_detector_cfg( imvoxel_net_cfg = get_detector_cfg(
'imvoxelnet/imvoxelnet_8xb4_kitti-3d-car.py') 'imvoxelnet/imvoxelnet_8xb4_kitti-3d-car.py')
model = MODELS.build(imvoxel_net_cfg) model = MODELS.build(imvoxel_net_cfg)
num_gt_instance = 1 num_gt_instance = 1
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
with_points=False, with_points=False,
with_img=True, with_img=True,
img_size=(128, 128), img_size=(128, 128),
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestMVXNet(unittest.TestCase): class TestMVXNet(unittest.TestCase):
...@@ -15,14 +15,14 @@ class TestMVXNet(unittest.TestCase): ...@@ -15,14 +15,14 @@ class TestMVXNet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'DynamicMVXFasterRCNN') assert hasattr(mmdet3d.models, 'DynamicMVXFasterRCNN')
_setup_seed(0) setup_seed(0)
DefaultScope.get_instance('test_mvxnet', scope_name='mmdet3d') DefaultScope.get_instance('test_mvxnet', scope_name='mmdet3d')
mvx_net_cfg = _get_detector_cfg( mvx_net_cfg = get_detector_cfg(
'mvxnet/mvxnet_fpn_dv_second_secfpn_8xb2-80e_kitti-3d-3class.py' # noqa 'mvxnet/mvxnet_fpn_dv_second_secfpn_8xb2-80e_kitti-3d-3class.py' # noqa
) )
model = MODELS.build(mvx_net_cfg) model = MODELS.build(mvx_net_cfg)
num_gt_instance = 1 num_gt_instance = 1
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
with_img=False, num_gt_instance=num_gt_instance, points_feat_dim=4) with_img=False, num_gt_instance=num_gt_instance, points_feat_dim=4)
if torch.cuda.is_available(): if torch.cuda.is_available():
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestPartA2(unittest.TestCase): class TestPartA2(unittest.TestCase):
...@@ -15,18 +15,17 @@ class TestPartA2(unittest.TestCase): ...@@ -15,18 +15,17 @@ class TestPartA2(unittest.TestCase):
assert hasattr(mmdet3d.models, 'PartA2') assert hasattr(mmdet3d.models, 'PartA2')
DefaultScope.get_instance('test_parta2', scope_name='mmdet3d') DefaultScope.get_instance('test_parta2', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
parta2_cfg = _get_detector_cfg( parta2_cfg = get_detector_cfg(
'parta2/PartA2_hv_secfpn_8xb2-cyclic-80e_kitti-3d-3class.py') 'parta2/PartA2_hv_secfpn_8xb2-cyclic-80e_kitti-3d-3class.py')
model = MODELS.build(parta2_cfg) model = MODELS.build(parta2_cfg)
num_gt_instance = 2 num_gt_instance = 2
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(num_gt_instance=num_gt_instance)
num_gt_instance=num_gt_instance)
# TODO: Support aug data test # TODO: Support aug data test
# aug_packed_inputs = [ # aug_packed_inputs = [
# _create_detector_inputs(num_gt_instance=num_gt_instance), # create_detector_inputs(num_gt_instance=num_gt_instance),
# _create_detector_inputs(num_gt_instance=num_gt_instance + 1) # create_detector_inputs(num_gt_instance=num_gt_instance + 1)
# ] # ]
# test_aug_test # test_aug_test
# metainfo = { # metainfo = {
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestPointRCNN(unittest.TestCase): class TestPointRCNN(unittest.TestCase):
...@@ -15,12 +15,12 @@ class TestPointRCNN(unittest.TestCase): ...@@ -15,12 +15,12 @@ class TestPointRCNN(unittest.TestCase):
assert hasattr(mmdet3d.models, 'PointRCNN') assert hasattr(mmdet3d.models, 'PointRCNN')
DefaultScope.get_instance('test_pointrcnn', scope_name='mmdet3d') DefaultScope.get_instance('test_pointrcnn', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
pointrcnn_cfg = _get_detector_cfg( pointrcnn_cfg = get_detector_cfg(
'point_rcnn/point-rcnn_8xb2_kitti-3d-3class.py') 'point_rcnn/point-rcnn_8xb2_kitti-3d-3class.py')
model = MODELS.build(pointrcnn_cfg) model = MODELS.build(pointrcnn_cfg)
num_gt_instance = 2 num_gt_instance = 2
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
num_points=10101, num_gt_instance=num_gt_instance) num_points=10101, num_gt_instance=num_gt_instance)
if torch.cuda.is_available(): if torch.cuda.is_available():
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestPVRCNN(unittest.TestCase): class TestPVRCNN(unittest.TestCase):
...@@ -15,18 +15,17 @@ class TestPVRCNN(unittest.TestCase): ...@@ -15,18 +15,17 @@ class TestPVRCNN(unittest.TestCase):
assert hasattr(mmdet3d.models, 'PointVoxelRCNN') assert hasattr(mmdet3d.models, 'PointVoxelRCNN')
DefaultScope.get_instance('test_pvrcnn', scope_name='mmdet3d') DefaultScope.get_instance('test_pvrcnn', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
pvrcnn_cfg = _get_detector_cfg( pvrcnn_cfg = get_detector_cfg(
'pvrcnn/pvrcnn_8xb2-80e_kitti-3d-3class.py') 'pvrcnn/pvrcnn_8xb2-80e_kitti-3d-3class.py')
model = MODELS.build(pvrcnn_cfg) model = MODELS.build(pvrcnn_cfg)
num_gt_instance = 2 num_gt_instance = 2
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(num_gt_instance=num_gt_instance)
num_gt_instance=num_gt_instance)
# TODO: Support aug data test # TODO: Support aug data test
# aug_packed_inputs = [ # aug_packed_inputs = [
# _create_detector_inputs(num_gt_instance=num_gt_instance), # create_detector_inputs(num_gt_instance=num_gt_instance),
# _create_detector_inputs(num_gt_instance=num_gt_instance + 1) # create_detector_inputs(num_gt_instance=num_gt_instance + 1)
# ] # ]
# test_aug_test # test_aug_test
# metainfo = { # metainfo = {
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestSDSSD(unittest.TestCase): class TestSDSSD(unittest.TestCase):
...@@ -15,12 +15,12 @@ class TestSDSSD(unittest.TestCase): ...@@ -15,12 +15,12 @@ class TestSDSSD(unittest.TestCase):
assert hasattr(mmdet3d.models, 'SASSD') assert hasattr(mmdet3d.models, 'SASSD')
DefaultScope.get_instance('test_sassd', scope_name='mmdet3d') DefaultScope.get_instance('test_sassd', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
voxel_net_cfg = _get_detector_cfg( voxel_net_cfg = get_detector_cfg(
'sassd/sassd_8xb6-80e_kitti-3d-3class.py') 'sassd/sassd_8xb6-80e_kitti-3d-3class.py')
model = MODELS.build(voxel_net_cfg) model = MODELS.build(voxel_net_cfg)
num_gt_instance = 3 num_gt_instance = 3
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(
num_gt_instance=num_gt_instance, num_classes=1) num_gt_instance=num_gt_instance, num_classes=1)
if torch.cuda.is_available(): if torch.cuda.is_available():
......
...@@ -4,8 +4,8 @@ import torch ...@@ -4,8 +4,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestVotenet(unittest.TestCase): class TestVotenet(unittest.TestCase):
...@@ -15,18 +15,16 @@ class TestVotenet(unittest.TestCase): ...@@ -15,18 +15,16 @@ class TestVotenet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'VoteNet') assert hasattr(mmdet3d.models, 'VoteNet')
DefaultScope.get_instance('test_vote_net', scope_name='mmdet3d') DefaultScope.get_instance('test_vote_net', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
voxel_net_cfg = _get_detector_cfg( voxel_net_cfg = get_detector_cfg('votenet/votenet_8xb16_sunrgbd-3d.py')
'votenet/votenet_8xb16_sunrgbd-3d.py')
model = MODELS.build(voxel_net_cfg) model = MODELS.build(voxel_net_cfg)
num_gt_instance = 50 num_gt_instance = 50
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(num_gt_instance=num_gt_instance)
num_gt_instance=num_gt_instance)
# TODO: Support aug test # TODO: Support aug test
# aug_data = [ # aug_data = [
# _create_detector_inputs(num_gt_instance=num_gt_instance), # create_detector_inputs(num_gt_instance=num_gt_instance),
# _create_detector_inputs(num_gt_instance=num_gt_instance + 1) # create_detector_inputs(num_gt_instance=num_gt_instance + 1)
# ] # ]
# # test_aug_test # # test_aug_test
# metainfo = { # metainfo = {
......
...@@ -5,8 +5,8 @@ import torch ...@@ -5,8 +5,8 @@ import torch
from mmengine import DefaultScope from mmengine import DefaultScope
from mmdet3d.registry import MODELS from mmdet3d.registry import MODELS
from tests.utils.model_utils import (_create_detector_inputs, from mmdet3d.testing import (create_detector_inputs, get_detector_cfg,
_get_detector_cfg, _setup_seed) setup_seed)
class TestVoxelNet(unittest.TestCase): class TestVoxelNet(unittest.TestCase):
...@@ -16,18 +16,17 @@ class TestVoxelNet(unittest.TestCase): ...@@ -16,18 +16,17 @@ class TestVoxelNet(unittest.TestCase):
assert hasattr(mmdet3d.models, 'VoxelNet') assert hasattr(mmdet3d.models, 'VoxelNet')
DefaultScope.get_instance('test_voxelnet', scope_name='mmdet3d') DefaultScope.get_instance('test_voxelnet', scope_name='mmdet3d')
_setup_seed(0) setup_seed(0)
pointpillars_cfg = _get_detector_cfg( pointpillars_cfg = get_detector_cfg(
'pointpillars/pointpillars_hv_secfpn_8xb6-160e_kitti-3d-3class.py') 'pointpillars/pointpillars_hv_secfpn_8xb6-160e_kitti-3d-3class.py')
model = MODELS.build(pointpillars_cfg) model = MODELS.build(pointpillars_cfg)
num_gt_instance = 2 num_gt_instance = 2
packed_inputs = _create_detector_inputs( packed_inputs = create_detector_inputs(num_gt_instance=num_gt_instance)
num_gt_instance=num_gt_instance)
# TODO: Support aug_test # TODO: Support aug_test
# aug_data = [ # aug_data = [
# _create_detector_inputs(num_gt_instance=num_gt_instance), # create_detector_inputs(num_gt_instance=num_gt_instance),
# _create_detector_inputs(num_gt_instance=num_gt_instance + 1) # create_detector_inputs(num_gt_instance=num_gt_instance + 1)
# ] # ]
# # test_aug_test # # test_aug_test
# metainfo = { # metainfo = {
......
...@@ -45,8 +45,8 @@ def test_centerpoint_fpn(): ...@@ -45,8 +45,8 @@ def test_centerpoint_fpn():
second_cfg = dict( second_cfg = dict(
type='SECOND', type='SECOND',
in_channels=64, in_channels=2,
out_channels=[64, 128, 256], out_channels=[2, 2, 2],
layer_nums=[3, 5, 5], layer_nums=[3, 5, 5],
layer_strides=[2, 2, 2], layer_strides=[2, 2, 2],
norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01),
...@@ -57,8 +57,8 @@ def test_centerpoint_fpn(): ...@@ -57,8 +57,8 @@ def test_centerpoint_fpn():
# centerpoint usage of fpn # centerpoint usage of fpn
centerpoint_fpn_cfg = dict( centerpoint_fpn_cfg = dict(
type='SECONDFPN', type='SECONDFPN',
in_channels=[64, 128, 256], in_channels=[2, 2, 2],
out_channels=[128, 128, 128], out_channels=[2, 2, 2],
upsample_strides=[0.5, 1, 2], upsample_strides=[0.5, 1, 2],
norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01),
upsample_cfg=dict(type='deconv', bias=False), upsample_cfg=dict(type='deconv', bias=False),
...@@ -67,17 +67,17 @@ def test_centerpoint_fpn(): ...@@ -67,17 +67,17 @@ def test_centerpoint_fpn():
# original usage of fpn # original usage of fpn
fpn_cfg = dict( fpn_cfg = dict(
type='SECONDFPN', type='SECONDFPN',
in_channels=[64, 128, 256], in_channels=[2, 2, 2],
upsample_strides=[1, 2, 4], upsample_strides=[1, 2, 4],
out_channels=[128, 128, 128]) out_channels=[2, 2, 2])
second_fpn = build_neck(fpn_cfg) second_fpn = build_neck(fpn_cfg)
centerpoint_second_fpn = build_neck(centerpoint_fpn_cfg) centerpoint_second_fpn = build_neck(centerpoint_fpn_cfg)
input = torch.rand([4, 64, 512, 512]) input = torch.rand([2, 2, 32, 32])
sec_output = second(input) sec_output = second(input)
centerpoint_output = centerpoint_second_fpn(sec_output) centerpoint_output = centerpoint_second_fpn(sec_output)
second_output = second_fpn(sec_output) second_output = second_fpn(sec_output)
assert centerpoint_output[0].shape == torch.Size([4, 384, 128, 128]) assert centerpoint_output[0].shape == torch.Size([2, 6, 8, 8])
assert second_output[0].shape == torch.Size([4, 384, 256, 256]) assert second_output[0].shape == torch.Size([2, 6, 16, 16])
...@@ -45,10 +45,10 @@ def test_anchor_3d_range_generator(): ...@@ -45,10 +45,10 @@ def test_anchor_3d_range_generator():
'\nrotations=[0, 1.57],\nreshape_out=False,' \ '\nrotations=[0, 1.57],\nreshape_out=False,' \
'\nsize_per_range=True)' '\nsize_per_range=True)'
assert repr_str == expected_repr_str assert repr_str == expected_repr_str
featmap_size = (256, 256) featmap_size = (8, 8)
mr_anchors = anchor_generator.single_level_grid_anchors( mr_anchors = anchor_generator.single_level_grid_anchors(
featmap_size, 1.1, device=device) featmap_size, 1.1, device=device)
assert mr_anchors.shape == torch.Size([1, 256, 256, 3, 2, 7]) assert mr_anchors.shape == torch.Size([1, 8, 8, 3, 2, 7])
def test_aligned_anchor_generator(): def test_aligned_anchor_generator():
...@@ -80,108 +80,108 @@ def test_aligned_anchor_generator(): ...@@ -80,108 +80,108 @@ def test_aligned_anchor_generator():
size_per_range=False, size_per_range=False,
reshape_out=True) reshape_out=True)
featmap_sizes = [(256, 256), (128, 128), (64, 64)] featmap_sizes = [(16, 16), (8, 8), (4, 4)]
anchor_generator = TASK_UTILS.build(anchor_generator_cfg) anchor_generator = TASK_UTILS.build(anchor_generator_cfg)
assert anchor_generator.num_base_anchors == 8 assert anchor_generator.num_base_anchors == 8
# check base anchors # check base anchors
expected_grid_anchors = [ expected_grid_anchors = [
torch.tensor([[ torch.tensor([[
-51.0000, -51.0000, -1.8000, 2.5981, 0.8660, 1.0000, 0.0000, -48.0000, -48.0000, -1.8000, 2.5981, 0.8660, 1.0000, 0.0000,
0.0000, 0.0000 0.0000, 0.0000
], ],
[ [
-51.0000, -51.0000, -1.8000, 0.4000, 0.4000, 1.0000, -48.0000, -48.0000, -1.8000, 0.4000, 0.4000, 1.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-50.6000, -51.0000, -1.8000, 0.4000, 0.4000, 1.0000, -41.6000, -48.0000, -1.8000, 0.4000, 0.4000, 1.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-50.2000, -51.0000, -1.8000, 1.0000, 1.0000, 1.0000, -35.2000, -48.0000, -1.8000, 1.0000, 1.0000, 1.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-49.8000, -51.0000, -1.8000, 1.0000, 1.0000, 1.0000, -28.8000, -48.0000, -1.8000, 1.0000, 1.0000, 1.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-49.4000, -51.0000, -1.8000, 1.7321, 0.5774, 1.0000, -22.4000, -48.0000, -1.8000, 1.7321, 0.5774, 1.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-49.0000, -51.0000, -1.8000, 1.7321, 0.5774, 1.0000, -16.0000, -48.0000, -1.8000, 1.7321, 0.5774, 1.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-48.6000, -51.0000, -1.8000, 2.5981, 0.8660, 1.0000, -9.6000, -48.0000, -1.8000, 2.5981, 0.8660, 1.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
]], ]],
device=device), device=device),
torch.tensor([[ torch.tensor([[
-50.8000, -50.8000, -1.8000, 5.1962, 1.7320, 2.0000, 0.0000, -44.8000, -44.8000, -1.8000, 5.1962, 1.7320, 2.0000, 0.0000,
0.0000, 0.0000 0.0000, 0.0000
], ],
[ [
-50.8000, -50.8000, -1.8000, 0.8000, 0.8000, 2.0000, -44.8000, -44.8000, -1.8000, 0.8000, 0.8000, 2.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-50.0000, -50.8000, -1.8000, 0.8000, 0.8000, 2.0000, -32.0000, -44.8000, -1.8000, 0.8000, 0.8000, 2.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-49.2000, -50.8000, -1.8000, 2.0000, 2.0000, 2.0000, -19.2000, -44.8000, -1.8000, 2.0000, 2.0000, 2.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-48.4000, -50.8000, -1.8000, 2.0000, 2.0000, 2.0000, -6.4000, -44.8000, -1.8000, 2.0000, 2.0000, 2.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-47.6000, -50.8000, -1.8000, 3.4642, 1.1548, 2.0000, 6.4000, -44.8000, -1.8000, 3.4642, 1.1548, 2.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-46.8000, -50.8000, -1.8000, 3.4642, 1.1548, 2.0000, 19.2000, -44.8000, -1.8000, 3.4642, 1.1548, 2.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-46.0000, -50.8000, -1.8000, 5.1962, 1.7320, 2.0000, 32.0000, -44.8000, -1.8000, 5.1962, 1.7320, 2.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
]], ]],
device=device), device=device),
torch.tensor([[ torch.tensor([[
-50.4000, -50.4000, -1.8000, 10.3924, 3.4640, 4.0000, 0.0000, -38.4000, -38.4000, -1.8000, 10.3924, 3.4640, 4.0000, 0.0000,
0.0000, 0.0000 0.0000, 0.0000
], ],
[ [
-50.4000, -50.4000, -1.8000, 1.6000, 1.6000, 4.0000, -38.4000, -38.4000, -1.8000, 1.6000, 1.6000, 4.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-48.8000, -50.4000, -1.8000, 1.6000, 1.6000, 4.0000, -12.8000, -38.4000, -1.8000, 1.6000, 1.6000, 4.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-47.2000, -50.4000, -1.8000, 4.0000, 4.0000, 4.0000, 12.8000, -38.4000, -1.8000, 4.0000, 4.0000, 4.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-45.6000, -50.4000, -1.8000, 4.0000, 4.0000, 4.0000, 38.4000, -38.4000, -1.8000, 4.0000, 4.0000, 4.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-44.0000, -50.4000, -1.8000, 6.9284, 2.3096, 4.0000, -38.4000, -12.8000, -1.8000, 6.9284, 2.3096, 4.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
], ],
[ [
-42.4000, -50.4000, -1.8000, 6.9284, 2.3096, 4.0000, -12.8000, -12.8000, -1.8000, 6.9284, 2.3096, 4.0000,
0.0000, 0.0000, 0.0000 0.0000, 0.0000, 0.0000
], ],
[ [
-40.8000, -50.4000, -1.8000, 10.3924, 3.4640, 4.0000, 12.8000, -12.8000, -1.8000, 10.3924, 3.4640, 4.0000,
1.5700, 0.0000, 0.0000 1.5700, 0.0000, 0.0000
]], ]],
device=device) device=device)
...@@ -189,9 +189,9 @@ def test_aligned_anchor_generator(): ...@@ -189,9 +189,9 @@ def test_aligned_anchor_generator():
multi_level_anchors = anchor_generator.grid_anchors( multi_level_anchors = anchor_generator.grid_anchors(
featmap_sizes, device=device) featmap_sizes, device=device)
expected_multi_level_shapes = [ expected_multi_level_shapes = [
torch.Size([524288, 9]), torch.Size([2048, 9]),
torch.Size([131072, 9]), torch.Size([512, 9]),
torch.Size([32768, 9]) torch.Size([128, 9])
] ]
for i, single_level_anchor in enumerate(multi_level_anchors): for i, single_level_anchor in enumerate(multi_level_anchors):
assert single_level_anchor.shape == expected_multi_level_shapes[i] assert single_level_anchor.shape == expected_multi_level_shapes[i]
......
...@@ -6,17 +6,15 @@ from mmdet3d.models.task_modules.voxel import VoxelGenerator ...@@ -6,17 +6,15 @@ from mmdet3d.models.task_modules.voxel import VoxelGenerator
def test_voxel_generator(): def test_voxel_generator():
np.random.seed(0) np.random.seed(0)
voxel_size = [0.5, 0.5, 0.5] voxel_size = [5, 5, 1]
point_cloud_range = [0, -40, -3, 70.4, 40, 1] point_cloud_range = [0, 0, 0, 20, 40, 4]
max_num_points = 1000 max_num_points = 5
self = VoxelGenerator(voxel_size, point_cloud_range, max_num_points) self = VoxelGenerator(voxel_size, point_cloud_range, max_num_points)
points = np.random.rand(1000, 4) points = np.random.uniform(0, 4, (20, 3))
voxels = self.generate(points) voxels = self.generate(points)
voxels, coors, num_points_per_voxel = voxels voxels, coors, num_points_per_voxel = voxels
expected_coors = np.array([[7, 81, 1], [6, 81, 0], [7, 80, 1], [6, 81, 1], expected_coors = np.array([[2, 0, 0], [3, 0, 0], [0, 0, 0], [1, 0, 0]])
[7, 81, 0], [6, 80, 1], [7, 80, 0], [6, 80, 0]]) expected_num_points_per_voxel = np.array([5, 5, 5, 3])
expected_num_points_per_voxel = np.array( assert voxels.shape == (4, 5, 3)
[120, 121, 127, 134, 115, 127, 125, 131])
assert voxels.shape == (8, 1000, 4)
assert np.all(coors == expected_coors) assert np.all(coors == expected_coors)
assert np.all(num_points_per_voxel == expected_num_points_per_voxel) assert np.all(num_points_per_voxel == expected_num_points_per_voxel)
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