Skip to content

Commit

Permalink
[Fix] Remove the legacy hack function for monocular dataset browsing (#…
Browse files Browse the repository at this point in the history
…794)

* Remove the legacy hack function for monocular dataset browsing

* Remove legacy import from stucture/__init__.py

* Remove legacy hacks for nuScenes visualization

* Add deleted show_bboxes initialization in inference.py

* Rollback deletion of hack function in core

* Adjust the deprecationwarning
  • Loading branch information
Tai-Wang authored Jul 31, 2021
1 parent 5258fe9 commit f6b59ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
11 changes: 4 additions & 7 deletions mmdet3d/apis/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from mmcv.runner import load_checkpoint
from os import path as osp

from mmdet3d.core import (Box3DMode, DepthInstance3DBoxes,
LiDARInstance3DBoxes, show_multi_modality_result,
show_result, show_seg_result)
from mmdet3d.core import (Box3DMode, CameraInstance3DBoxes,
DepthInstance3DBoxes, LiDARInstance3DBoxes,
show_multi_modality_result, show_result,
show_seg_result)
from mmdet3d.core.bbox import get_box_type
from mmdet3d.core.bbox.structures.cam_box3d import CameraInstance3DBoxes
from mmdet3d.datasets.pipelines import Compose
from mmdet3d.models import build_model

Expand Down Expand Up @@ -427,11 +427,8 @@ def show_proj_det_result_meshlab(data,
raise NotImplementedError(
'camera intrinsic matrix is not provided')

from mmdet3d.core.bbox import mono_cam_box2vis
show_bboxes = CameraInstance3DBoxes(
pred_bboxes, box_dim=pred_bboxes.shape[-1], origin=(0.5, 1.0, 0.5))
# TODO: remove the hack of box from NuScenesMonoDataset
show_bboxes = mono_cam_box2vis(show_bboxes)

show_multi_modality_result(
img,
Expand Down
4 changes: 4 additions & 0 deletions mmdet3d/core/bbox/structures/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import torch
from logging import warning


def limit_period(val, offset=0.5, period=np.pi):
Expand Down Expand Up @@ -167,6 +168,9 @@ def mono_cam_box2vis(cam_box):
Returns:
:obj:`CameraInstance3DBoxes`: Box after conversion.
"""
warning.warn('DeprecationWarning: The hack of yaw and dimension in the '
'monocular 3D detection on nuScenes has been removed. The '
'function mono_cam_box2vis will be deprecated.')
from . import CameraInstance3DBoxes
assert isinstance(cam_box, CameraInstance3DBoxes), \
'input bbox should be CameraInstance3DBoxes!'
Expand Down
5 changes: 1 addition & 4 deletions mmdet3d/datasets/nuscenes_mono_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mmdet3d.core import bbox3d2result, box3d_multiclass_nms, xywhr2xyxyr
from mmdet.datasets import DATASETS, CocoDataset
from ..core import show_multi_modality_result
from ..core.bbox import CameraInstance3DBoxes, get_box_type, mono_cam_box2vis
from ..core.bbox import CameraInstance3DBoxes, get_box_type
from .pipelines import Compose
from .utils import extract_result_dict, get_loading_pipeline

Expand Down Expand Up @@ -624,9 +624,6 @@ def show(self, results, out_dir, show=True, pipeline=None):
img = img.numpy().transpose(1, 2, 0)
gt_bboxes = self.get_ann_info(i)['gt_bboxes_3d']
pred_bboxes = result['boxes_3d']
# TODO: remove the hack of box from NuScenesMonoDataset
gt_bboxes = mono_cam_box2vis(gt_bboxes)
pred_bboxes = mono_cam_box2vis(pred_bboxes)
show_multi_modality_result(
img,
gt_bboxes,
Expand Down
5 changes: 1 addition & 4 deletions mmdet3d/models/detectors/single_stage_mono3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from os import path as osp

from mmdet3d.core import (CameraInstance3DBoxes, bbox3d2result,
mono_cam_box2vis, show_multi_modality_result)
show_multi_modality_result)
from mmdet.models.builder import DETECTORS
from mmdet.models.detectors.single_stage import SingleStageDetector

Expand Down Expand Up @@ -207,9 +207,6 @@ def show_results(self, data, result, out_dir):
assert isinstance(pred_bboxes, CameraInstance3DBoxes), \
f'unsupported predicted bbox type {type(pred_bboxes)}'

# TODO: remove the hack of box from NuScenesMonoDataset
pred_bboxes = mono_cam_box2vis(pred_bboxes)

show_multi_modality_result(
img,
None,
Expand Down

0 comments on commit f6b59ae

Please sign in to comment.