Unverified Commit 7d072d60 authored by VVsssssk's avatar VVsssssk Committed by GitHub
Browse files

[Fix] Fix nus metric and cbgs (#1753)

* fix nus metric and CBGS

* add nus namemap

* fix comments

* fix comments
parent 31faf9fc
......@@ -19,7 +19,7 @@ nus_attributes = ('cycle.with_rider', 'cycle.without_rider',
'pedestrian.moving', 'pedestrian.standing',
'pedestrian.sitting_lying_down', 'vehicle.moving',
'vehicle.parked', 'vehicle.stopped', 'None')
NameMapping = {
NuScenesNameMapping = {
'movable_object.barrier': 'barrier',
'vehicle.bicycle': 'bicycle',
'vehicle.bus.bendy': 'bus',
......@@ -35,6 +35,17 @@ NameMapping = {
'vehicle.trailer': 'trailer',
'vehicle.truck': 'truck'
}
LyftNameMapping = {
'bicycle': 'bicycle',
'bus': 'bus',
'car': 'car',
'emergency_vehicle': 'emergency_vehicle',
'motorcycle': 'motorcycle',
'other_vehicle': 'other_vehicle',
'pedestrian': 'pedestrian',
'truck': 'truck',
'animal': 'animal'
}
def get_2d_boxes(nusc, sample_data_token: str, visibilities: List[str]):
......@@ -390,9 +401,9 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float,
repro_rec['bbox_corners'] = [x1, y1, x2, y2]
repro_rec['filename'] = filename
if repro_rec['category_name'] not in NameMapping:
if repro_rec['category_name'] not in NuScenesNameMapping:
return None
cat_name = NameMapping[repro_rec['category_name']]
cat_name = NuScenesNameMapping[repro_rec['category_name']]
coco_rec['bbox_label'] = nus_categories.index(cat_name)
coco_rec['bbox_label_3d'] = nus_categories.index(cat_name)
coco_rec['bbox'] = [x1, y1, x2, y2]
......
......@@ -18,7 +18,8 @@ class CBGSDataset(object):
def __init__(self, dataset):
self.dataset = DATASETS.build(dataset)
self.CLASSES = self.dataset.metainfo['CLASSES']
self.metainfo = self.dataset.metainfo
self.CLASSES = self.metainfo['CLASSES']
self.cat2id = {name: i for i, name in enumerate(self.CLASSES)}
self.sample_indices = self._get_sample_indices()
# self.dataset.data_infos = self.data_infos
......
......@@ -490,7 +490,7 @@ class NuScenesMetric(BaseMetric):
print('Start to convert detection format...')
for i, det in enumerate(mmengine.track_iter_progress(results)):
annos = []
boxes = output_to_nusc_box(det)
boxes, attrs = output_to_nusc_box(det)
sample_id = sample_id_list[i]
sample_token = self.data_infos[sample_id]['token']
boxes = lidar_nusc_box_to_global(self.data_infos[sample_id], boxes,
......
......@@ -9,7 +9,7 @@ import numpy as np
from lyft_dataset_sdk.lyftdataset import LyftDataset as Lyft
from pyquaternion import Quaternion
from mmdet3d.datasets import LyftDataset
from mmdet3d.datasets.convert_utils import LyftNameMapping
from .nuscenes_converter import (get_2d_boxes, get_available_scenes,
obtain_sensor2top)
......@@ -190,8 +190,8 @@ def _fill_trainval_infos(lyft,
names = [b.name for b in boxes]
for i in range(len(names)):
if names[i] in LyftDataset.NameMapping:
names[i] = LyftDataset.NameMapping[names[i]]
if names[i] in LyftNameMapping:
names[i] = LyftNameMapping[names[i]]
names = np.array(names)
# we need to convert box size to
......
......@@ -12,7 +12,7 @@ from nuscenes.utils.geometry_utils import view_points
from pyquaternion import Quaternion
from shapely.geometry import MultiPoint, box
from mmdet3d.datasets import NuScenesDataset
from mmdet3d.datasets.convert_utils import NuScenesNameMapping
from mmdet3d.structures import points_cam2img
nus_categories = ('car', 'truck', 'trailer', 'bus', 'construction_vehicle',
......@@ -248,8 +248,8 @@ def _fill_trainval_infos(nusc,
names = [b.name for b in boxes]
for i in range(len(names)):
if names[i] in NuScenesDataset.NameMapping:
names[i] = NuScenesDataset.NameMapping[names[i]]
if names[i] in NuScenesNameMapping:
names[i] = NuScenesNameMapping[names[i]]
names = np.array(names)
# we need to convert box size to
# the format of our lidar coordinate system
......@@ -618,9 +618,9 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float,
coco_rec['image_id'] = sample_data_token
coco_rec['area'] = (y2 - y1) * (x2 - x1)
if repro_rec['category_name'] not in NuScenesDataset.NameMapping:
if repro_rec['category_name'] not in NuScenesNameMapping:
return None
cat_name = NuScenesDataset.NameMapping[repro_rec['category_name']]
cat_name = NuScenesNameMapping[repro_rec['category_name']]
coco_rec['category_name'] = cat_name
coco_rec['category_id'] = nus_categories.index(cat_name)
coco_rec['bbox'] = [x1, y1, x2 - x1, y2 - y1]
......
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