Unverified Commit 4e4d6e97 authored by yinchimaoliang's avatar yinchimaoliang Committed by GitHub
Browse files

Add transforms_3d unittest (#12)



* Support github action:

* fix docs package

* reduce action items

* Update cuda arch

* Set cuda arch

* Add information

* add cocotools in installation

* skip gpu

* remove duplicated module

* Change points shape from 1177 to 800

* Change 1177 to 800

* Change 1177 to 800

* Add print

* Add other print

* Change gt_labels

* Add seed

* Change to len assert

* Change gt_bboxes_3d

* Change repr
Co-authored-by: default avatarZwwWayne <wayne.zw@outlook.com>
Co-authored-by: default avatarliyinhao <liyinhao@sensetime.com>
parent f842ff96
...@@ -206,7 +206,15 @@ class ObjectSample(object): ...@@ -206,7 +206,15 @@ class ObjectSample(object):
def __repr__(self): def __repr__(self):
"""str: Return a string that describes the module.""" """str: Return a string that describes the module."""
return self.__class__.__name__ repr_str = self.__class__.__name__
repr_str += f' sample_2d={self.sample_2d},'
repr_str += f' data_root={self.sampler_cfg.data_root},'
repr_str += f' info_path={self.sampler_cfg.info_path},'
repr_str += f' rate={self.sampler_cfg.rate},'
repr_str += f' prepare={self.sampler_cfg.prepare},'
repr_str += f' classes={self.sampler_cfg.classes},'
repr_str += f' sample_groups={self.sampler_cfg.sample_groups}'
return repr_str
@PIPELINES.register_module() @PIPELINES.register_module()
......
...@@ -2,7 +2,7 @@ import mmcv ...@@ -2,7 +2,7 @@ import mmcv
import numpy as np import numpy as np
import torch import torch
from mmdet3d.core import Box3DMode, CameraInstance3DBoxes from mmdet3d.core import Box3DMode, CameraInstance3DBoxes, LiDARInstance3DBoxes
from mmdet3d.datasets import ObjectNoise, ObjectSample from mmdet3d.datasets import ObjectNoise, ObjectSample
...@@ -34,6 +34,64 @@ def test_remove_points_in_boxes(): ...@@ -34,6 +34,64 @@ def test_remove_points_in_boxes():
assert points.shape == (10, 4) assert points.shape == (10, 4)
def test_object_sample():
import pickle
db_sampler = mmcv.ConfigDict({
'data_root': './tests/data/kitti/',
'info_path': './tests/data/kitti/kitti_dbinfos_train.pkl',
'rate': 1.0,
'prepare': {
'filter_by_difficulty': [-1],
'filter_by_min_points': {
'Pedestrian': 10
}
},
'classes': ['Pedestrian', 'Cyclist', 'Car'],
'sample_groups': {
'Pedestrian': 6
}
})
with open('./tests/data/kitti/kitti_dbinfos_train.pkl', 'rb') as f:
db_infos = pickle.load(f)
np.random.seed(0)
object_sample = ObjectSample(db_sampler)
points = np.fromfile(
'./tests/data/kitti/training/velodyne_reduced/000000.bin',
np.float32).reshape(-1, 4)
annos = mmcv.load('./tests/data/kitti/kitti_infos_train.pkl')
info = annos[0]
annos = info['annos']
gt_names = annos['name']
gt_bboxes_3d = db_infos['Pedestrian'][0]['box3d_lidar']
gt_bboxes_3d = LiDARInstance3DBoxes([gt_bboxes_3d])
CLASSES = ('Car', 'Pedestrian', 'Cyclist')
gt_labels = []
for cat in gt_names:
if cat in CLASSES:
gt_labels.append(CLASSES.index(cat))
else:
gt_labels.append(-1)
input_dict = dict(
points=points, gt_bboxes_3d=gt_bboxes_3d, gt_labels_3d=gt_labels)
input_dict = object_sample(input_dict)
points = input_dict['points']
gt_bboxes_3d = input_dict['gt_bboxes_3d']
gt_labels_3d = input_dict['gt_labels_3d']
repr_str = repr(object_sample)
expected_repr_str = 'ObjectSample sample_2d=False, ' \
'data_root=./tests/data/kitti/, ' \
'info_path=./tests/data/kitti/kitti' \
'_dbinfos_train.pkl, rate=1.0, ' \
'prepare={\'filter_by_difficulty\': [-1], ' \
'\'filter_by_min_points\': {\'Pedestrian\': 10}}, ' \
'classes=[\'Pedestrian\', \'Cyclist\', \'Car\'], ' \
'sample_groups={\'Pedestrian\': 6}'
assert repr_str == expected_repr_str
assert points.shape == (1177, 4)
assert gt_bboxes_3d.tensor.shape == (2, 7)
assert np.all(gt_labels_3d == [1, 0])
def test_object_noise(): def test_object_noise():
np.random.seed(0) np.random.seed(0)
object_noise = ObjectNoise() object_noise = ObjectNoise()
......
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