Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
7d072d60
Unverified
Commit
7d072d60
authored
Aug 26, 2022
by
VVsssssk
Committed by
GitHub
Aug 26, 2022
Browse files
[Fix] Fix nus metric and cbgs (#1753)
* fix nus metric and CBGS * add nus namemap * fix comments * fix comments
parent
31faf9fc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
13 deletions
+25
-13
mmdet3d/datasets/convert_utils.py
mmdet3d/datasets/convert_utils.py
+14
-3
mmdet3d/datasets/dataset_wrappers.py
mmdet3d/datasets/dataset_wrappers.py
+2
-1
mmdet3d/evaluation/metrics/nuscenes_metric.py
mmdet3d/evaluation/metrics/nuscenes_metric.py
+1
-1
tools/dataset_converters/lyft_converter.py
tools/dataset_converters/lyft_converter.py
+3
-3
tools/dataset_converters/nuscenes_converter.py
tools/dataset_converters/nuscenes_converter.py
+5
-5
No files found.
mmdet3d/datasets/convert_utils.py
View file @
7d072d60
...
...
@@ -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
=
{
NuScenes
NameMapping
=
{
'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
NuScenes
NameMapping
:
return
None
cat_name
=
NameMapping
[
repro_rec
[
'category_name'
]]
cat_name
=
NuScenes
NameMapping
[
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
]
...
...
mmdet3d/datasets/dataset_wrappers.py
View file @
7d072d60
...
...
@@ -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
...
...
mmdet3d/evaluation/metrics/nuscenes_metric.py
View file @
7d072d60
...
...
@@ -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
,
...
...
tools/dataset_converters/lyft_converter.py
View file @
7d072d60
...
...
@@ -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
Lyft
Dataset
from
mmdet3d.datasets
.convert_utils
import
Lyft
NameMapping
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
Lyft
Dataset
.
NameMapping
:
names
[
i
]
=
Lyft
Dataset
.
NameMapping
[
names
[
i
]]
if
names
[
i
]
in
LyftNameMapping
:
names
[
i
]
=
LyftNameMapping
[
names
[
i
]]
names
=
np
.
array
(
names
)
# we need to convert box size to
...
...
tools/dataset_converters/nuscenes_converter.py
View file @
7d072d60
...
...
@@ -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
NuScenes
Dataset
from
mmdet3d.datasets
.convert_utils
import
NuScenes
NameMapping
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
NuScenes
Dataset
.
NameMapping
:
names
[
i
]
=
NuScenes
Dataset
.
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
NuScenes
Dataset
.
NameMapping
:
if
repro_rec
[
'category_name'
]
not
in
NuScenesNameMapping
:
return
None
cat_name
=
NuScenes
Dataset
.
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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment