Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]Lift the NUSC_BOX_TO_CAM_BOX3D dependence on CUDA. #2851

Open
wants to merge 2 commits into
base: dev-1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mmdet3d/evaluation/metrics/nuscenes_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pyquaternion
import torch
from mmengine import Config, load
from mmengine.device import get_device
from mmengine.evaluator import BaseMetric
from mmengine.logging import MMLogger
from nuscenes.eval.detection.config import config_factory
Expand Down Expand Up @@ -767,6 +768,7 @@ def nusc_box_to_cam_box3d(
Tuple[:obj:`CameraInstance3DBoxes`, torch.Tensor, torch.Tensor]:
Converted 3D bounding boxes, scores and labels.
"""
device = get_device()
locs = torch.Tensor([b.center for b in boxes]).view(-1, 3)
dims = torch.Tensor([b.wlh for b in boxes]).view(-1, 3)
rots = torch.Tensor([b.orientation.yaw_pitch_roll[0]
Expand All @@ -777,11 +779,11 @@ def nusc_box_to_cam_box3d(
dims[:, [0, 1, 2]] = dims[:, [1, 2, 0]]
rots = -rots

boxes_3d = torch.cat([locs, dims, rots, velocity], dim=1).cuda()
boxes_3d = torch.cat([locs, dims, rots, velocity], dim=1).to(device=device)
cam_boxes3d = CameraInstance3DBoxes(
boxes_3d, box_dim=9, origin=(0.5, 0.5, 0.5))
scores = torch.Tensor([b.score for b in boxes]).cuda()
labels = torch.LongTensor([b.label for b in boxes]).cuda()
scores = torch.Tensor([b.score for b in boxes]).to(device=device)
labels = torch.LongTensor([b.label for b in boxes]).to(device=device)
nms_scores = scores.new_zeros(scores.shape[0], 10 + 1)
indices = labels.new_tensor(list(range(scores.shape[0])))
nms_scores[indices, labels] = scores
Expand Down
Loading