diff --git a/mmdet3d/core/bbox/structures/utils.py b/mmdet3d/core/bbox/structures/utils.py index fe63f9de11..9d36330940 100644 --- a/mmdet3d/core/bbox/structures/utils.py +++ b/mmdet3d/core/bbox/structures/utils.py @@ -175,10 +175,10 @@ def mono_cam_box2vis(cam_box): assert isinstance(cam_box, CameraInstance3DBoxes), \ 'input bbox should be CameraInstance3DBoxes!' - loc = cam_box.gravity_center - dim = cam_box.dims - yaw = cam_box.yaw - feats = cam_box.tensor[:, 7:] + loc = cam_box.gravity_center.clone() + dim = cam_box.dims.clone() + yaw = cam_box.yaw.clone() + feats = cam_box.tensor[:, 7:].clone() # rotate along x-axis for np.pi / 2 # see also here: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/datasets/nuscenes_mono_dataset.py#L557 # noqa dim[:, [1, 2]] = dim[:, [2, 1]] @@ -189,8 +189,8 @@ def mono_cam_box2vis(cam_box): # this is because mono 3D box class such as `NuScenesBox` has different # definition of rotation with our `CameraInstance3DBoxes` yaw = -yaw - np.pi / 2 - cam_box = torch.cat([loc, dim, yaw[:, None], feats], dim=1) - cam_box = CameraInstance3DBoxes( - cam_box, box_dim=cam_box.shape[-1], origin=(0.5, 0.5, 0.5)) + new_cam_box = torch.cat([loc, dim, yaw[:, None], feats], dim=1) + new_cam_box = CameraInstance3DBoxes( + new_cam_box, box_dim=new_cam_box.shape[-1], origin=(0.5, 0.5, 0.5)) - return cam_box + return new_cam_box diff --git a/mmdet3d/core/visualizer/image_vis.py b/mmdet3d/core/visualizer/image_vis.py index 94c415835e..75f925f48c 100644 --- a/mmdet3d/core/visualizer/image_vis.py +++ b/mmdet3d/core/visualizer/image_vis.py @@ -182,6 +182,8 @@ def draw_camera_bbox3d_on_img(bboxes3d, img = raw_img.copy() cam2img = copy.deepcopy(cam2img) + if len(bboxes3d.tensor) is 0: + return img corners_3d = bboxes3d.corners num_bbox = corners_3d.shape[0] points_3d = corners_3d.reshape(-1, 3) diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index 1792bfb0f6..ef2ac5eaeb 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -2,6 +2,7 @@ import numpy as np import trimesh from os import path as osp +from os import environ from .image_vis import (draw_camera_bbox3d_on_img, draw_depth_bbox3d_on_img, draw_lidar_bbox3d_on_img) @@ -92,7 +93,7 @@ def show_result(points, result_path = osp.join(out_dir, filename) mmcv.mkdir_or_exist(result_path) - if show: + if show and environ.get('DISPLAY'): from .open3d_vis import Visualizer vis = Visualizer(points) @@ -241,7 +242,7 @@ def show_multi_modality_result(img, result_path = osp.join(out_dir, filename) mmcv.mkdir_or_exist(result_path) - if show: + if show and environ.get('DISPLAY'): show_img = img.copy() if gt_bboxes is not None: show_img = draw_bbox( diff --git a/mmdet3d/datasets/nuscenes_dataset.py b/mmdet3d/datasets/nuscenes_dataset.py index a7d4b06375..9b31052e63 100644 --- a/mmdet3d/datasets/nuscenes_dataset.py +++ b/mmdet3d/datasets/nuscenes_dataset.py @@ -14,7 +14,7 @@ @DATASETS.register_module() class NuScenesDataset(Custom3DDataset): - r"""NuScenes Dataset. + """NuScenes Dataset. This class serves as the API for experiments on the NuScenes Dataset. diff --git a/mmdet3d/datasets/nuscenes_mono_dataset.py b/mmdet3d/datasets/nuscenes_mono_dataset.py index f3f1b0b1aa..6b9964871c 100644 --- a/mmdet3d/datasets/nuscenes_mono_dataset.py +++ b/mmdet3d/datasets/nuscenes_mono_dataset.py @@ -18,7 +18,7 @@ @DATASETS.register_module() class NuScenesMonoDataset(CocoDataset): - r"""Monocular 3D detection on NuScenes Dataset. + """Monocular 3D detection on NuScenes Dataset. This class serves as the API for experiments on the NuScenes Dataset. diff --git a/mmdet3d/datasets/pipelines/loading.py b/mmdet3d/datasets/pipelines/loading.py index d78b30599f..a3d71729cf 100644 --- a/mmdet3d/datasets/pipelines/loading.py +++ b/mmdet3d/datasets/pipelines/loading.py @@ -149,7 +149,7 @@ def _load_points(self, pts_filename): points = np.frombuffer(pts_bytes, dtype=np.float32) except ConnectionError: mmcv.check_file_exist(pts_filename) - if pts_filename.endswith('.npy'): + if pts_filename.endswith('.npy') or pts_filename.endswith('.npz'): points = np.load(pts_filename) else: points = np.fromfile(pts_filename, dtype=np.float32) @@ -390,7 +390,7 @@ def _load_points(self, pts_filename): points = np.frombuffer(pts_bytes, dtype=np.float32) except ConnectionError: mmcv.check_file_exist(pts_filename) - if pts_filename.endswith('.npy'): + if pts_filename.endswith('.npy') or pts_filename.endswith('.npz'): points = np.load(pts_filename) else: points = np.fromfile(pts_filename, dtype=np.float32) diff --git a/mmdet3d/ops/norm.py b/mmdet3d/ops/norm.py index e9db8fb579..00affe686b 100644 --- a/mmdet3d/ops/norm.py +++ b/mmdet3d/ops/norm.py @@ -54,7 +54,7 @@ def __init__(self, *args, **kwargs): def forward(self, input): assert input.dtype == torch.float32, \ f'input should be in float32 type, got {input.dtype}' - if dist.get_world_size() == 1 or not self.training: + if not dist.is_initialized() or dist.get_world_size() == 1 or not self.training: return super().forward(input) assert input.shape[0] > 0, 'SyncBN does not support empty inputs' C = input.shape[1] @@ -108,7 +108,7 @@ def __init__(self, *args, **kwargs): def forward(self, input): assert input.dtype == torch.float32, \ f'input should be in float32 type, got {input.dtype}' - if dist.get_world_size() == 1 or not self.training: + if not dist.is_initialized() or dist.get_world_size() == 1 or not self.training: return super().forward(input) assert input.shape[0] > 0, 'SyncBN does not support empty inputs'