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
mmdetection3d
Commits
c2fe651f
Commit
c2fe651f
authored
Jul 20, 2022
by
zhangshilong
Committed by
ChaimZhu
Jul 20, 2022
Browse files
refactor directory
parent
bc5806ba
Changes
275
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
87 additions
and
179 deletions
+87
-179
tests/test_models/test_decode_heads/test_dgcnn_head.py
tests/test_models/test_decode_heads/test_dgcnn_head.py
+1
-1
tests/test_models/test_decode_heads/test_paconv_head.py
tests/test_models/test_decode_heads/test_paconv_head.py
+1
-1
tests/test_models/test_decode_heads/test_pointnet2_head.py
tests/test_models/test_decode_heads/test_pointnet2_head.py
+1
-1
tests/test_models/test_dense_heads/test_anchor3d_head.py
tests/test_models/test_dense_heads/test_anchor3d_head.py
+1
-1
tests/test_models/test_dense_heads/test_fcos_mono3d_head.py
tests/test_models/test_dense_heads/test_fcos_mono3d_head.py
+1
-1
tests/test_models/test_dense_heads/test_freeanchors.py
tests/test_models/test_dense_heads/test_freeanchors.py
+3
-2
tests/test_models/test_dense_heads/test_pgd_head.py
tests/test_models/test_dense_heads/test_pgd_head.py
+1
-1
tests/test_models/test_dense_heads/test_smoke_mono3d_head.py
tests/test_models/test_dense_heads/test_smoke_mono3d_head.py
+1
-1
tests/test_models/test_dense_heads/test_ssn.py
tests/test_models/test_dense_heads/test_ssn.py
+1
-1
tests/test_models/test_detectors/test_3dssd.py
tests/test_models/test_detectors/test_3dssd.py
+1
-0
tests/test_models/test_detectors/test_center_point.py
tests/test_models/test_detectors/test_center_point.py
+3
-2
tests/test_models/test_detectors/test_groupfree3d.py
tests/test_models/test_detectors/test_groupfree3d.py
+1
-0
tests/test_models/test_detectors/test_h3d.py
tests/test_models/test_detectors/test_h3d.py
+0
-51
tests/test_models/test_detectors/test_imvotenet.py
tests/test_models/test_detectors/test_imvotenet.py
+1
-0
tests/test_models/test_detectors/test_imvoxelnet.py
tests/test_models/test_detectors/test_imvoxelnet.py
+3
-2
tests/test_models/test_detectors/test_mvxnet.py
tests/test_models/test_detectors/test_mvxnet.py
+2
-1
tests/test_models/test_detectors/test_parta2.py
tests/test_models/test_detectors/test_parta2.py
+2
-1
tests/test_models/test_detectors/test_votenet.py
tests/test_models/test_detectors/test_votenet.py
+1
-1
tests/test_models/test_detectors/test_voxelnet.py
tests/test_models/test_detectors/test_voxelnet.py
+61
-110
tests/test_models/test_fusion_layers/test_fusion_coord_trans.py
...test_models/test_fusion_layers/test_fusion_coord_trans.py
+1
-1
No files found.
tests/test_models/test_decode_heads/test_dgcnn_head.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ from unittest import TestCase
import
torch
from
mmdet3d.core
import
Det3DDataSample
,
PointData
from
mmdet3d.models.decode_heads
import
DGCNNHead
from
mmdet3d.structures
import
Det3DDataSample
,
PointData
class
TestDGCNNHead
(
TestCase
):
...
...
tests/test_models/test_decode_heads/test_paconv_head.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ from unittest import TestCase
import
torch
from
mmdet3d.core
import
Det3DDataSample
,
PointData
from
mmdet3d.models.decode_heads
import
PAConvHead
from
mmdet3d.structures
import
Det3DDataSample
,
PointData
class
TestPAConvHead
(
TestCase
):
...
...
tests/test_models/test_decode_heads/test_pointnet2_head.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ from unittest import TestCase
import
torch
from
mmdet3d.core
import
Det3DDataSample
,
PointData
from
mmdet3d.models.decode_heads
import
PointNet2Head
from
mmdet3d.structures
import
Det3DDataSample
,
PointData
class
TestPointNet2Head
(
TestCase
):
...
...
tests/test_models/test_dense_heads/test_anchor3d_head.py
View file @
c2fe651f
...
...
@@ -6,8 +6,8 @@ from mmengine import Config
from
mmengine.data
import
InstanceData
from
mmdet3d
import
*
# noqa
from
mmdet3d.core.bbox
import
Box3DMode
,
LiDARInstance3DBoxes
from
mmdet3d.models.dense_heads
import
Anchor3DHead
from
mmdet3d.structures
import
Box3DMode
,
LiDARInstance3DBoxes
class
TestAnchor3DHead
(
TestCase
):
...
...
tests/test_models/test_dense_heads/test_fcos_mono3d_head.py
View file @
c2fe651f
...
...
@@ -6,8 +6,8 @@ import numpy as np
import
torch
from
mmengine.data
import
InstanceData
from
mmdet3d.core.bbox
import
CameraInstance3DBoxes
from
mmdet3d.models.dense_heads
import
FCOSMono3DHead
from
mmdet3d.structures
import
CameraInstance3DBoxes
class
TestFCOSMono3DHead
(
TestCase
):
...
...
tests/test_models/test_dense_heads/test_freeanchors.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ import unittest
import
torch
from
mmengine
import
DefaultScope
from
mmdet3d.core
import
LiDARInstance3DBoxes
from
mmdet3d.registry
import
MODELS
from
mmdet3d.structures
import
LiDARInstance3DBoxes
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
...
...
@@ -21,7 +21,7 @@ class TestFreeAnchor(unittest.TestCase):
'free_anchor/hv_pointpillars_fpn_sbn-all_free-'
'anchor_4x8_2x_nus-3d.py'
)
model
=
MODELS
.
build
(
freeanchor_cfg
)
num_gt_instance
=
50
num_gt_instance
=
3
data
=
[
_create_detector_inputs
(
num_gt_instance
=
num_gt_instance
,
gt_bboxes_dim
=
9
)
...
...
@@ -47,6 +47,7 @@ class TestFreeAnchor(unittest.TestCase):
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
...
...
tests/test_models/test_dense_heads/test_pgd_head.py
View file @
c2fe651f
...
...
@@ -6,8 +6,8 @@ import numpy as np
import
torch
from
mmengine.data
import
InstanceData
from
mmdet3d.core.bbox
import
CameraInstance3DBoxes
from
mmdet3d.models.dense_heads
import
PGDHead
from
mmdet3d.structures
import
CameraInstance3DBoxes
class
TestFGDHead
(
TestCase
):
...
...
tests/test_models/test_dense_heads/test_smoke_mono3d_head.py
View file @
c2fe651f
...
...
@@ -5,8 +5,8 @@ import numpy as np
import
torch
from
mmengine.data
import
InstanceData
from
mmdet3d.core.bbox
import
CameraInstance3DBoxes
from
mmdet3d.models.dense_heads
import
SMOKEMono3DHead
from
mmdet3d.structures
import
CameraInstance3DBoxes
class
TestSMOKEMono3DHead
(
TestCase
):
...
...
tests/test_models/test_dense_heads/test_ssn.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ import unittest
import
torch
from
mmengine
import
DefaultScope
from
mmdet3d.core
import
LiDARInstance3DBoxes
from
mmdet3d.registry
import
MODELS
from
mmdet3d.structures
import
LiDARInstance3DBoxes
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
...
...
tests/test_models/test_detectors/test_3dssd.py
View file @
c2fe651f
...
...
@@ -30,6 +30,7 @@ class Test3DSSD(unittest.TestCase):
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
...
...
tests/test_models/test_detectors/test_center_point.py
View file @
c2fe651f
...
...
@@ -41,8 +41,9 @@ class TestCenterPoint(unittest.TestCase):
# test simple_test
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
with
torch
.
no_grad
():
torch
.
cuda
.
empty_cache
()
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
assert
losses
[
'task0.loss_heatmap'
]
>=
0
assert
losses
[
'task0.loss_bbox'
]
>=
0
assert
losses
[
'task1.loss_heatmap'
]
>=
0
...
...
tests/test_models/test_detectors/test_groupfree3d.py
View file @
c2fe651f
...
...
@@ -34,6 +34,7 @@ class TestGroupfree3d(unittest.TestCase):
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
...
...
tests/test_models/test_detectors/test_h3d.py
deleted
100644 → 0
View file @
bc5806ba
import
unittest
import
torch
from
mmengine
import
DefaultScope
from
mmdet3d.registry
import
MODELS
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
class
TestH3D
(
unittest
.
TestCase
):
def
test_h3dnet
(
self
):
import
mmdet3d.models
assert
hasattr
(
mmdet3d
.
models
,
'H3DNet'
)
DefaultScope
.
get_instance
(
'test_H3DNet'
,
scope_name
=
'mmdet3d'
)
_setup_seed
(
0
)
voxel_net_cfg
=
_get_detector_cfg
(
'h3dnet/h3dnet_3x8_scannet-3d-18class.py'
)
model
=
MODELS
.
build
(
voxel_net_cfg
)
num_gt_instance
=
5
data
=
[
_create_detector_inputs
(
num_gt_instance
=
num_gt_instance
,
points_feat_dim
=
4
,
bboxes_3d_type
=
'depth'
,
with_pts_semantic_mask
=
True
,
with_pts_instance_mask
=
True
)
]
if
torch
.
cuda
.
is_available
():
model
=
model
.
cuda
()
# test simple_test
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
self
.
assertIn
(
'bboxes_3d'
,
results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'scores_3d'
,
results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'labels_3d'
,
results
[
0
].
pred_instances_3d
)
# save the memory
with
torch
.
no_grad
():
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
self
.
assertGreater
(
losses
[
'vote_loss'
],
0
)
self
.
assertGreater
(
losses
[
'objectness_loss'
],
0
)
self
.
assertGreater
(
losses
[
'center_loss'
],
0
)
tests/test_models/test_detectors/test_imvotenet.py
View file @
c2fe651f
...
...
@@ -41,6 +41,7 @@ class TestImvoteNet(unittest.TestCase):
# save the memory
with
torch
.
no_grad
():
torch
.
cuda
.
empty_cache
()
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
self
.
assertGreater
(
sum
(
losses
[
'loss_rpn_cls'
]),
0
)
...
...
tests/test_models/test_detectors/test_imvoxelnet.py
View file @
c2fe651f
...
...
@@ -10,7 +10,7 @@ from tests.utils.model_utils import (_create_detector_inputs,
class
TestImVoxelNet
(
unittest
.
TestCase
):
def
test_
h3d
net
(
self
):
def
test_
imvoxel
net
(
self
):
import
mmdet3d.models
assert
hasattr
(
mmdet3d
.
models
,
'ImVoxelNet'
)
...
...
@@ -24,7 +24,7 @@ class TestImVoxelNet(unittest.TestCase):
_create_detector_inputs
(
with_points
=
False
,
with_img
=
True
,
img_size
=
(
384
,
128
0
),
img_size
=
(
128
,
128
),
num_gt_instance
=
num_gt_instance
,
with_pts_semantic_mask
=
False
,
with_pts_instance_mask
=
False
)
...
...
@@ -36,6 +36,7 @@ class TestImVoxelNet(unittest.TestCase):
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
...
...
tests/test_models/test_detectors/test_mvxnet.py
View file @
c2fe651f
...
...
@@ -21,7 +21,7 @@ class TestMVXNet(unittest.TestCase):
'mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py'
# noqa
)
model
=
MODELS
.
build
(
mvx_net_cfg
)
num_gt_instance
=
50
num_gt_instance
=
1
data
=
[
_create_detector_inputs
(
with_img
=
False
,
...
...
@@ -36,6 +36,7 @@ class TestMVXNet(unittest.TestCase):
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
# save the memory when do the unitest
with
torch
.
no_grad
():
torch
.
cuda
.
empty_cache
()
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
assert
losses
[
'loss_cls'
][
0
]
>=
0
assert
losses
[
'loss_bbox'
][
0
]
>=
0
...
...
tests/test_models/test_detectors/test_parta2.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ import unittest
import
torch
from
mmengine
import
DefaultScope
from
mmdet3d.core
import
LiDARInstance3DBoxes
from
mmdet3d.registry
import
MODELS
from
mmdet3d.structures
import
LiDARInstance3DBoxes
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
...
...
@@ -41,6 +41,7 @@ class TestPartA2(unittest.TestCase):
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
...
...
tests/test_models/test_detectors/test_votenet.py
View file @
c2fe651f
...
...
@@ -3,8 +3,8 @@ import unittest
import
torch
from
mmengine
import
DefaultScope
from
mmdet3d.core
import
LiDARInstance3DBoxes
from
mmdet3d.registry
import
MODELS
from
mmdet3d.structures
import
LiDARInstance3DBoxes
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
...
...
tests/test_models/test_detectors/test_voxelnet.py
View file @
c2fe651f
# Copyright (c) OpenMMLab. All rights reserved.
import
pytest
import
unittest
import
torch
from
mmengine
.data
import
InstanceData
from
mmengine
import
DefaultScope
from
mmdet3d.core
import
Det3DDataSample
from
mmdet3d.core.bbox
import
LiDARInstance3DBoxes
from
mmdet3d.registry
import
MODELS
from
tests.utils.model_utils
import
_get_detector_cfg
,
_setup_seed
def
test_voxel_net
():
import
mmdet3d.models
assert
hasattr
(
mmdet3d
.
models
,
'VoxelNet'
)
if
not
torch
.
cuda
.
is_available
():
pytest
.
skip
(
'test requires GPU and torch+cuda'
)
_setup_seed
(
0
)
voxel_net_cfg
=
_get_detector_cfg
(
'pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py'
)
model
=
MODELS
.
build
(
voxel_net_cfg
).
cuda
()
input_dict0
=
dict
(
points
=
torch
.
rand
([
2010
,
4
],
device
=
'cuda'
))
input_dict1
=
dict
(
points
=
torch
.
rand
([
2020
,
4
],
device
=
'cuda'
))
gt_instance_3d_0
=
InstanceData
()
gt_instance_3d_0
.
bboxes_3d
=
LiDARInstance3DBoxes
(
torch
.
rand
([
20
,
7
],
device
=
'cuda'
))
gt_instance_3d_0
.
labels_3d
=
torch
.
randint
(
0
,
3
,
[
20
],
device
=
'cuda'
)
data_sample_0
=
Det3DDataSample
(
metainfo
=
dict
(
box_type_3d
=
LiDARInstance3DBoxes
))
data_sample_0
.
gt_instances_3d
=
gt_instance_3d_0
gt_instance_3d_1
=
InstanceData
()
gt_instance_3d_1
.
bboxes_3d
=
LiDARInstance3DBoxes
(
torch
.
rand
([
50
,
7
],
device
=
'cuda'
))
gt_instance_3d_1
.
labels_3d
=
torch
.
randint
(
0
,
3
,
[
50
],
device
=
'cuda'
)
data_sample_1
=
Det3DDataSample
(
metainfo
=
dict
(
box_type_3d
=
LiDARInstance3DBoxes
))
data_sample_1
.
gt_instances_3d
=
gt_instance_3d_1
data
=
[
dict
(
inputs
=
input_dict0
,
data_sample
=
data_sample_0
)]
# test simple_test
# TODO FIX this UT
pytest
.
skip
(
'FIX this @shenkun'
)
with
torch
.
no_grad
():
results
=
model
.
forward
(
data
,
return_loss
=
False
)
bboxes_3d
=
results
[
0
].
pred_instances_3d
[
'bboxes_3d'
]
scores_3d
=
results
[
0
].
pred_instances_3d
[
'scores_3d'
]
labels_3d
=
results
[
0
].
pred_instances_3d
[
'labels_3d'
]
assert
bboxes_3d
.
tensor
.
shape
==
(
50
,
7
)
assert
scores_3d
.
shape
==
torch
.
Size
([
50
])
assert
labels_3d
.
shape
==
torch
.
Size
([
50
])
# test forward_train
data
=
[
dict
(
inputs
=
input_dict0
,
data_sample
=
data_sample_0
),
dict
(
inputs
=
input_dict1
,
data_sample
=
data_sample_1
)
]
losses
=
model
.
forward
(
data
,
return_loss
=
True
)
assert
losses
[
'log_vars'
][
'loss_cls'
]
>=
0
assert
losses
[
'log_vars'
][
'loss_bbox'
]
>=
0
assert
losses
[
'log_vars'
][
'loss_dir'
]
>=
0
assert
losses
[
'log_vars'
][
'loss'
]
>=
0
# test_aug_test
metainfo
=
{
'pcd_scale_factor'
:
1
,
'pcd_horizontal_flip'
:
1
,
'pcd_vertical_flip'
:
1
,
'box_type_3d'
:
LiDARInstance3DBoxes
}
data_sample_0
.
set_metainfo
(
metainfo
)
data_sample_1
.
set_metainfo
(
metainfo
)
data
=
[
dict
(
inputs
=
input_dict0
,
data_sample
=
data_sample_0
),
dict
(
inputs
=
input_dict1
,
data_sample
=
data_sample_1
)
]
model
.
forward
(
data
,
return_loss
=
False
)
from
mmdet3d.structures
import
LiDARInstance3DBoxes
from
tests.utils.model_utils
import
(
_create_detector_inputs
,
_get_detector_cfg
,
_setup_seed
)
def
test_sassd
():
# TODO fix this unitest
pytest
.
skip
(
'FIX this'
)
if
not
torch
.
cuda
.
is_available
():
pytest
.
skip
(
'test requires GPU and torch+cuda'
)
_setup_seed
(
0
)
sassd_cfg
=
_get_detector_cfg
(
'sassd/sassd_6x8_80e_kitti-3d-3class.py'
)
class
TestVoxelNet
(
unittest
.
TestCase
):
self
=
build_detector
(
sassd_cfg
).
cuda
()
points_0
=
torch
.
rand
([
2010
,
4
],
device
=
'cuda'
)
points_1
=
torch
.
rand
([
2020
,
4
],
device
=
'cuda'
)
points
=
[
points_0
,
points_1
]
gt_bbox_0
=
LiDARInstance3DBoxes
(
torch
.
rand
([
10
,
7
],
device
=
'cuda'
))
gt_bbox_1
=
LiDARInstance3DBoxes
(
torch
.
rand
([
10
,
7
],
device
=
'cuda'
))
gt_bboxes
=
[
gt_bbox_0
,
gt_bbox_1
]
gt_labels_0
=
torch
.
randint
(
0
,
3
,
[
10
],
device
=
'cuda'
)
gt_labels_1
=
torch
.
randint
(
0
,
3
,
[
10
],
device
=
'cuda'
)
gt_labels
=
[
gt_labels_0
,
gt_labels_1
]
img_meta_0
=
dict
(
box_type_3d
=
LiDARInstance3DBoxes
)
img_meta_1
=
dict
(
box_type_3d
=
LiDARInstance3DBoxes
)
img_metas
=
[
img_meta_0
,
img_meta_1
]
def
test_voxelnet
(
self
):
import
mmdet3d.models
# test forward_train
losses
=
self
.
forward_train
(
points
,
img_metas
,
gt_bboxes
,
gt_labels
)
assert
losses
[
'loss_cls'
][
0
]
>=
0
assert
losses
[
'loss_bbox'
][
0
]
>=
0
assert
losses
[
'loss_dir'
][
0
]
>=
0
assert
losses
[
'aux_loss_cls'
][
0
]
>=
0
assert
losses
[
'aux_loss_reg'
][
0
]
>=
0
assert
hasattr
(
mmdet3d
.
models
,
'VoxelNet'
)
DefaultScope
.
get_instance
(
'test_voxelnet'
,
scope_name
=
'mmdet3d'
)
_setup_seed
(
0
)
pointpillars_cfg
=
_get_detector_cfg
(
'pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class.py'
)
model
=
MODELS
.
build
(
pointpillars_cfg
)
num_gt_instance
=
2
data
=
[
_create_detector_inputs
(
num_gt_instance
=
num_gt_instance
)]
aug_data
=
[
_create_detector_inputs
(
num_gt_instance
=
num_gt_instance
),
_create_detector_inputs
(
num_gt_instance
=
num_gt_instance
+
1
)
]
# test_aug_test
metainfo
=
{
'pcd_scale_factor'
:
1
,
'pcd_horizontal_flip'
:
1
,
'pcd_vertical_flip'
:
1
,
'box_type_3d'
:
LiDARInstance3DBoxes
}
for
item
in
aug_data
:
item
[
'data_sample'
].
set_metainfo
(
metainfo
)
if
torch
.
cuda
.
is_available
():
model
=
model
.
cuda
()
# test simple_test
with
torch
.
no_grad
():
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
data
,
True
)
torch
.
cuda
.
empty_cache
()
results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
self
.
assertIn
(
'bboxes_3d'
,
results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'scores_3d'
,
results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'labels_3d'
,
results
[
0
].
pred_instances_3d
)
batch_inputs
,
data_samples
=
model
.
data_preprocessor
(
aug_data
,
True
)
aug_results
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'predict'
)
self
.
assertEqual
(
len
(
results
),
len
(
data
))
self
.
assertIn
(
'bboxes_3d'
,
aug_results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'scores_3d'
,
aug_results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'labels_3d'
,
aug_results
[
0
].
pred_instances_3d
)
self
.
assertIn
(
'bboxes_3d'
,
aug_results
[
1
].
pred_instances_3d
)
self
.
assertIn
(
'scores_3d'
,
aug_results
[
1
].
pred_instances_3d
)
self
.
assertIn
(
'labels_3d'
,
aug_results
[
1
].
pred_instances_3d
)
# save the memory
# test simple_test
with
torch
.
no_grad
():
results
=
self
.
simple_test
(
points
,
img_metas
)
boxes_3d
=
results
[
0
][
'boxes_3d'
]
scores_3d
=
results
[
0
][
'scores_3d'
]
labels_3d
=
results
[
0
][
'labels_3d'
]
assert
boxes_3d
.
tensor
.
shape
==
(
50
,
7
)
assert
scores_3d
.
shape
==
torch
.
Size
([
50
])
assert
labels_3d
.
shape
==
torch
.
Size
([
50
])
with
torch
.
no_grad
():
losses
=
model
.
forward
(
batch_inputs
,
data_samples
,
mode
=
'loss'
)
torch
.
cuda
.
empty_cache
()
self
.
assertGreater
(
losses
[
'loss_dir'
][
0
],
0
)
self
.
assertGreater
(
losses
[
'loss_bbox'
][
0
],
0
)
self
.
assertGreater
(
losses
[
'loss_cls'
][
0
],
0
)
tests/test_models/test_fusion_layers/test_fusion_coord_trans.py
View file @
c2fe651f
...
...
@@ -7,7 +7,7 @@ CommandLine:
import
torch
from
mmdet3d.models.fusion_layers
import
apply_3d_transformation
from
mmdet3d.models.
layers.
fusion_layers
import
apply_3d_transformation
def
test_coords_transformation
():
...
...
Prev
1
…
9
10
11
12
13
14
Next
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