Skip to content

Commit

Permalink
Merge branch 'dev-1.x' into inferencer_lidar_seg
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangxu-0103 committed Mar 2, 2023
2 parents 14df7a2 + ae3c8f8 commit cd4b6b2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
18 changes: 13 additions & 5 deletions mmdet3d/datasets/transforms/formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,13 @@ def pack_single_results(self, results: dict) -> dict:
if 'img' in results:
if isinstance(results['img'], list):
# process multiple imgs in single frame
imgs = [to_tensor(img) for img in results['img']]
imgs = torch.stack(
imgs, dim=0).permute(0, 3, 1, 2).contiguous()
results['img'] = to_tensor(imgs)
imgs = np.stack(results['img'], axis=0)
if imgs.flags.c_contiguous:
imgs = to_tensor(imgs).permute(0, 3, 1, 2).contiguous()
else:
imgs = to_tensor(
np.ascontiguousarray(imgs.transpose(0, 3, 1, 2)))
results['img'] = imgs
else:
img = results['img']
if len(img.shape) < 3:
Expand All @@ -159,7 +162,12 @@ def pack_single_results(self, results: dict) -> dict:
# `torch.permute()` rather than `np.transpose()`.
# Refer to https://github.com/open-mmlab/mmdetection/pull/9533
# for more details
results['img'] = to_tensor(img).permute(2, 0, 1).contiguous()
if img.flags.c_contiguous:
img = to_tensor(img).permute(2, 0, 1).contiguous()
else:
img = to_tensor(
np.ascontiguousarray(img.transpose(2, 0, 1)))
results['img'] = img

for key in [
'proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels',
Expand Down
8 changes: 4 additions & 4 deletions mmdet3d/datasets/transforms/transforms_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2592,14 +2592,14 @@ def laser_mix_transform(self, input_dict: dict, mix_results: dict) -> dict:

rho = torch.sqrt(points.coord[:, 0]**2 + points.coord[:, 1]**2)
pitch = torch.atan2(points.coord[:, 2], rho)
pitch = torch.clip(pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)
pitch = torch.clamp(pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)

mix_rho = torch.sqrt(mix_points.coord[:, 0]**2 +
mix_points.coord[:, 1]**2)
mix_pitch = torch.atan2(mix_points.coord[:, 2], mix_rho)
mix_pitch = torch.clip(mix_pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)
mix_pitch = torch.clamp(mix_pitch, self.pitch_angles[0] + 1e-5,
self.pitch_angles[1] - 1e-5)

num_areas = np.random.choice(self.num_areas, size=1)[0]
angle_list = np.linspace(self.pitch_angles[1], self.pitch_angles[0],
Expand Down
28 changes: 20 additions & 8 deletions mmdet3d/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@

# manage all kinds of runners like `EpochBasedRunner` and `IterBasedRunner`
RUNNERS = Registry(
'runner', parent=MMENGINE_RUNNERS, locations=['mmdet3d.engine.runner'])
# TODO: update the location when mmdet3d has its own runner
'runner',
parent=MMENGINE_RUNNERS,
locations=['mmdet3d.engine'])
# manage runner constructors that define how to initialize runners
RUNNER_CONSTRUCTORS = Registry(
'runner constructor',
parent=MMENGINE_RUNNER_CONSTRUCTORS,
locations=['mmdet3d.engine.runner'])
# TODO: update the location when mmdet3d has its own runner
locations=['mmdet3d.engine'])
# manage all kinds of loops like `EpochBasedTrainLoop`
LOOPS = Registry(
'loop', parent=MMENGINE_LOOPS, locations=['mmdet3d.engine.runner'])
# TODO: update the location when mmdet3d has its own loop
'loop',
parent=MMENGINE_LOOPS,
locations=['mmdet3d.engine'])
# manage all kinds of hooks like `CheckpointHook`
HOOKS = Registry(
'hook', parent=MMENGINE_HOOKS, locations=['mmdet3d.engine.hooks'])
Expand All @@ -53,7 +60,8 @@
DATA_SAMPLERS = Registry(
'data sampler',
parent=MMENGINE_DATA_SAMPLERS,
locations=['mmdet3d.datasets.samplers'])
# TODO: update the location when mmdet3d has its own data sampler
locations=['mmdet3d.datasets'])
TRANSFORMS = Registry(
'transform',
parent=MMENGINE_TRANSFORMS,
Expand All @@ -77,22 +85,26 @@
OPTIMIZERS = Registry(
'optimizer',
parent=MMENGINE_OPTIMIZERS,
locations=['mmdet3d.engine.optimizers'])
# TODO: update the location when mmdet3d has its own optimizer
locations=['mmdet3d.engine'])
# manage optimizer wrapper
OPTIM_WRAPPERS = Registry(
'optim wrapper',
parent=MMENGINE_OPTIM_WRAPPERS,
locations=['mmdet3d.engine.optimizers'])
# TODO: update the location when mmdet3d has its own optimizer
locations=['mmdet3d.engine'])
# manage constructors that customize the optimization hyperparameters.
OPTIM_WRAPPER_CONSTRUCTORS = Registry(
'optimizer wrapper constructor',
parent=MMENGINE_OPTIM_WRAPPER_CONSTRUCTORS,
locations=['mmdet3d.engine.optimizers'])
# TODO: update the location when mmdet3d has its own optimizer
locations=['mmdet3d.engine'])
# mangage all kinds of parameter schedulers like `MultiStepLR`
PARAM_SCHEDULERS = Registry(
'parameter scheduler',
parent=MMENGINE_PARAM_SCHEDULERS,
locations=['mmdet3d.engine.schedulers'])
# TODO: update the location when mmdet3d has its own scheduler
locations=['mmdet3d.engine'])
# manage all kinds of metrics
METRICS = Registry(
'metric', parent=MMENGINE_METRICS, locations=['mmdet3d.evaluation'])
Expand Down

0 comments on commit cd4b6b2

Please sign in to comment.