Skip to content

Commit

Permalink
nuScenes-panoptic v1.0 release (nutonomy#628)
Browse files Browse the repository at this point in the history
* nuScenes-panoptic v1.0 code release, challenge announcement

* Add LSTQ panoptic tracking metric

* Fix jenkins failure

* Address review comments

* Address review comments
  • Loading branch information
lubing-motional authored Aug 3, 2021
1 parent 2c6a752 commit c44366d
Show file tree
Hide file tree
Showing 20 changed files with 2,322 additions and 241 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to the devkit of the [nuScenes](https://www.nuscenes.org/nuscenes) and [
- [Getting started with nuImages](#getting-started-with-nuimages)
- [nuScenes](#nuscenes)
- [nuScenes setup](#nuscenes-setup)
- [nuScenes-panoptic](#nuscenes-panoptic)
- [nuScenes-lidarseg](#nuscenes-lidarseg)
- [Prediction challenge](#prediction-challenge)
- [CAN bus expansion](#can-bus-expansion)
Expand All @@ -20,6 +21,7 @@ Welcome to the devkit of the [nuScenes](https://www.nuscenes.org/nuscenes) and [
- [Citation](#citation)

## Changelog
- Jul. 29, 2020: Devkit v1.2.0: nuScenes-panoptic v1.0 code, NeurIPS challenge announcement.
- Apr. 5, 2021: Devkit v1.1.3: Bug fixes and pip requirements.
- Nov. 23, 2020: Devkit v1.1.2: Release map-expansion v1.3 with lidar basemap.
- Nov. 9, 2020: Devkit v1.1.1: Lidarseg evaluation code, NeurIPS challenge announcement.
Expand Down Expand Up @@ -97,14 +99,23 @@ Eventually you should have the following folder structure:
```
If you want to use another folder, specify the `dataroot` parameter of the NuScenes class (see tutorial).

### nuScenes-panoptic
In August 2021 we published [nuScenes-panoptic](https://www.nuscenes.org/nuscenes) which contains the panoptic
labels of the point clouds for the approximately 40,000 keyframes in nuScenes.
To install nuScenes-panoptic, please follow these steps:
- Download the dataset from the [Download page](https://www.nuscenes.org/download),
- Extract the `panoptic` and `v1.0-*` folders to your nuScenes root directory (e.g. `/data/sets/nuscenes/panoptic`, `/data/sets/nuscenes/v1.0-*`).
- Get the latest version of the nuscenes-devkit.
- Get started with the [tutorial](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/tutorials/nuscenes_lidarseg_panoptic_tutorial.ipynb).

### nuScenes-lidarseg
In August 2020 we published [nuScenes-lidarseg](https://www.nuscenes.org/nuscenes#lidarseg) which contains the semantic labels of the point clouds for the approximately 40,000 keyframes in nuScenes.
To install nuScenes-lidarseg, please follow these steps:
- Download the dataset from the [Download page](https://www.nuscenes.org/download),
- Extract the `lidarseg` and `v1.0-*` folders to your nuScenes root directory (e.g. `/data/sets/nuscenes/lidarseg`, `/data/sets/nuscenes/v1.0-*`).
- Get the latest version of the nuscenes-devkit.
- If you already have a previous version of the devkit, update the pip requirements (see [details](https://github.com/nutonomy/nuscenes-devkit/blob/master/docs/installation.md)): `pip install -r setup/requirements.txt`
- Get started with the [tutorial](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/tutorials/nuscenes_lidarseg_tutorial.ipynb).
- Get started with the [tutorial](https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/tutorials/nuscenes_lidarseg_panoptic_tutorial.ipynb).

### Prediction challenge
In March 2020 we released code for the nuScenes prediction challenge.
Expand Down
2 changes: 1 addition & 1 deletion python-sdk/nuscenes/eval/lidarseg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The folder structure of the results should be as follows:
the submission
```

The contents of the `submision.json` file and `test` folder are defined below:
The contents of the `submission.json` file and `test` folder are defined below:
* The `submission.json` file includes meta data `meta` on the type of inputs used for this method.
```
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions python-sdk/nuscenes/eval/lidarseg/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import os
from typing import Dict

import numpy as np
from tqdm import tqdm

from nuscenes import NuScenes
from nuscenes.eval.lidarseg.utils import LidarsegClassMapper, ConfusionMatrix, get_samples_in_eval_set, load_bin_file
from nuscenes.eval.lidarseg.utils import ConfusionMatrix, LidarsegClassMapper, get_samples_in_eval_set
from nuscenes.utils.data_io import load_bin_file


class LidarSegEval:
Expand Down
5 changes: 3 additions & 2 deletions python-sdk/nuscenes/eval/lidarseg/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

from nuscenes import NuScenes
from nuscenes.eval.lidarseg.evaluate import LidarSegEval
from nuscenes.eval.lidarseg.utils import ConfusionMatrix, LidarsegClassMapper, load_bin_file, LidarSegPointCloud
from nuscenes.lidarseg.lidarseg_utils import colormap_to_colors, create_lidarseg_legend, get_labels_in_coloring
from nuscenes.eval.lidarseg.utils import ConfusionMatrix, LidarsegClassMapper
from nuscenes.lidarseg.lidarseg_utils import colormap_to_colors
from nuscenes.utils.data_classes import LidarSegPointCloud


class LidarSegEvalStratified(LidarSegEval):
Expand Down
80 changes: 0 additions & 80 deletions python-sdk/nuscenes/eval/lidarseg/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import os
from typing import Dict, List, Tuple

from matplotlib import axes
import numpy as np

from nuscenes import NuScenes
from nuscenes.lidarseg.lidarseg_utils import colormap_to_colors, create_lidarseg_legend, get_labels_in_coloring
from nuscenes.utils.data_classes import LidarPointCloud
from nuscenes.utils.splits import create_splits_scenes


Expand Down Expand Up @@ -357,78 +352,3 @@ def get_samples_in_eval_set(nusc: NuScenes, eval_set: str) -> List[str]:
'but only {} keyframes were processed'.format(total_num_samples, i)

return samples


def load_bin_file(bin_path: str) -> np.ndarray:
"""
Loads a .bin file containing the labels.
:param bin_path: Path to the .bin file.
:return: An array containing the labels.
"""
assert os.path.exists(bin_path), 'Error: Unable to find {}.'.format(bin_path)
bin_content = np.fromfile(bin_path, dtype=np.uint8)
assert len(bin_content) > 0, 'Error: {} is empty.'.format(bin_path)

return bin_content


class LidarSegPointCloud:
"""
Class for a point cloud.
"""
def __init__(self, points_path: str = None, labels_path: str = None):
"""
Initialize a LidarSegPointCloud object.
:param points_path: Path to the bin file containing the x, y, z and intensity of the points in the point cloud.
:param labels_path: Path to the bin file containing the labels of the points in the point cloud.
"""
self.points, self.labels = None, None
if points_path:
self.load_points(points_path)
if labels_path:
self.load_labels(labels_path)

def load_points(self, path: str) -> None:
"""
Loads the x, y, z and intensity of the points in the point cloud.
:param path: Path to the bin file containing the x, y, z and intensity of the points in the point cloud.
"""
self.points = LidarPointCloud.from_file(path).points.T # [N, 4], where N is the number of points.
if self.labels is not None:
assert len(self.points) == len(self.labels), 'Error: There are {} points in the point cloud, ' \
'but {} labels'.format(len(self.points), len(self.labels))

def load_labels(self, path: str) -> None:
"""
Loads the labels of the points in the point cloud.
:param path: Path to the bin file containing the labels of the points in the point cloud.
"""
self.labels = load_bin_file(path)
if self.points is not None:
assert len(self.points) == len(self.labels), 'Error: There are {} points in the point cloud, ' \
'but {} labels'.format(len(self.points), len(self.labels))

def render(self, name2color: Dict[str, Tuple[int]],
name2id: Dict[str, int],
ax: axes.Axes,
title: str = None,
dot_size: int = 5) -> axes.Axes:
"""
Renders a point cloud onto an axes.
:param name2color: The mapping from class name to class color.
:param name2id: A dictionary containing the mapping from class names to class indices.
:param ax: Axes onto which to render.
:param title: Title of the plot.
:param dot_size: Scatter plot dot size.
:return: The axes onto which the point cloud has been rendered.
"""
colors = colormap_to_colors(name2color, name2id)
ax.scatter(self.points[:, 0], self.points[:, 1], c=colors[self.labels], s=dot_size)

id2name = {idx: name for name, idx in name2id.items()}
create_lidarseg_legend(self.labels, id2name, name2color, ax=ax)

if title:
ax.set_title(title)

return ax
Loading

0 comments on commit c44366d

Please sign in to comment.