-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modules before mg_head in centerpoint (#46)
* Add centerpoint_rpn and scn, change pillar encoder and voxel_encoder * Move test_voxel_encoders. * Change names, add docstring. * Reconstruct centerpoint_rpn. * Add centerpoint_rpn. * Change SECONDFPN, delete centerpoint_fpn * Remove SparseBasicBlock. * Change SpMiddleResNetFHD to SparseEncoder. * Finish SparseEncoder unittest. * Change test_hard_simple_VFE. * Change option, add legacy. * Change docstring, change legacy. * Fix legacy bug. * Change unittest, change docstring. * Change docstring.
- Loading branch information
1 parent
5f7b31c
commit 27d0001
Showing
7 changed files
with
212 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
import torch | ||
|
||
from mmdet3d.models.builder import build_middle_encoder | ||
|
||
|
||
def test_sparse_encoder(): | ||
if not torch.cuda.is_available(): | ||
pytest.skip('test requires GPU and torch+cuda') | ||
sparse_encoder_cfg = dict( | ||
type='SparseEncoder', | ||
in_channels=5, | ||
sparse_shape=[40, 1024, 1024], | ||
order=('conv', 'norm', 'act'), | ||
encoder_channels=((16, 16, 32), (32, 32, 64), (64, 64, 128), (128, | ||
128)), | ||
encoder_paddings=((1, 1, 1), (1, 1, 1), (1, 1, 1), (1, 1, 1), (1, 1, | ||
1)), | ||
option='basicblock') | ||
|
||
sparse_encoder = build_middle_encoder(sparse_encoder_cfg).cuda() | ||
voxel_features = torch.rand([207842, 5]).cuda() | ||
coors = torch.randint(0, 4, [207842, 4]).cuda() | ||
|
||
ret = sparse_encoder(voxel_features, coors, 4) | ||
assert ret.shape == torch.Size([4, 256, 128, 128]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import torch | ||
|
||
from mmdet3d.models.builder import build_backbone, build_neck | ||
|
||
|
||
def test_centerpoint_fpn(): | ||
|
||
second_cfg = dict( | ||
type='SECOND', | ||
in_channels=64, | ||
out_channels=[64, 128, 256], | ||
layer_nums=[3, 5, 5], | ||
layer_strides=[2, 2, 2], | ||
norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), | ||
conv_cfg=dict(type='Conv2d', bias=False)) | ||
|
||
second = build_backbone(second_cfg) | ||
|
||
# centerpoint usage of fpn | ||
centerpoint_fpn_cfg = dict( | ||
type='SECONDFPN', | ||
in_channels=[64, 128, 256], | ||
out_channels=[128, 128, 128], | ||
upsample_strides=[0.5, 1, 2], | ||
norm_cfg=dict(type='BN', eps=1e-3, momentum=0.01), | ||
upsample_cfg=dict(type='deconv', bias=False), | ||
use_conv_for_no_stride=True) | ||
|
||
# original usage of fpn | ||
fpn_cfg = dict( | ||
type='SECONDFPN', | ||
in_channels=[64, 128, 256], | ||
upsample_strides=[1, 2, 4], | ||
out_channels=[128, 128, 128]) | ||
|
||
second_fpn = build_neck(fpn_cfg) | ||
|
||
centerpoint_second_fpn = build_neck(centerpoint_fpn_cfg) | ||
|
||
input = torch.rand([4, 64, 512, 512]) | ||
sec_output = second(input) | ||
centerpoint_output = centerpoint_second_fpn(sec_output) | ||
second_output = second_fpn(sec_output) | ||
assert centerpoint_output[0].shape == torch.Size([4, 384, 128, 128]) | ||
assert second_output[0].shape == torch.Size([4, 384, 256, 256]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import torch | ||
|
||
from mmdet3d.models.builder import build_voxel_encoder | ||
|
||
|
||
def test_pillar_feature_net(): | ||
pillar_feature_net_cfg = dict( | ||
type='PillarFeatureNet', | ||
in_channels=5, | ||
feat_channels=[64], | ||
with_distance=False, | ||
voxel_size=(0.2, 0.2, 8), | ||
point_cloud_range=(-51.2, -51.2, -5.0, 51.2, 51.2, 3.0), | ||
norm_cfg=dict(type='BN1d', eps=1e-3, momentum=0.01)) | ||
|
||
pillar_feature_net = build_voxel_encoder(pillar_feature_net_cfg) | ||
|
||
features = torch.rand([97297, 20, 5]) | ||
num_voxels = torch.randint(1, 100, [97297]) | ||
coors = torch.randint(0, 100, [97297, 4]) | ||
|
||
features = pillar_feature_net(features, num_voxels, coors) | ||
assert features.shape == torch.Size([97297, 64]) | ||
|
||
|
||
def test_hard_simple_VFE(): | ||
hard_simple_VFE_cfg = dict(type='HardSimpleVFE', num_features=5) | ||
hard_simple_VFE = build_voxel_encoder(hard_simple_VFE_cfg) | ||
features = torch.rand([240000, 10, 5]) | ||
num_voxels = torch.randint(1, 10, [240000]) | ||
|
||
outputs = hard_simple_VFE(features, num_voxels, None) | ||
assert outputs.shape == torch.Size([240000, 5]) |