Skip to content

Commit

Permalink
Panoptic labels generation fix (nutonomy#655)
Browse files Browse the repository at this point in the history
* fix panoptic labels generation
  • Loading branch information
lubing-motional authored Sep 4, 2021
1 parent d71e72d commit 84ee1f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python-sdk/nuscenes/eval/panoptic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ different segments.

### Multi-Object Panoptic Tracking
#### Panoptic Tracking Quality (PTQ)
We use PTQ [Juana et al.](https://arxiv.org/pdf/2004.08189.pdf) that extends PQ with the IoU of matched segments with
We use PTQ [Hurtado et al.](https://arxiv.org/pdf/2004.08189.pdf) that extends PQ with the IoU of matched segments with
track ID discrepancy, penalizing the incorrect track predictions. PTQ is defined as
(∑{**1**(p,g) IoU(p,g)} - |IDS|) / (|TP|+ 0.5|FP|+ 0.5|FN|), where IDS stands for ID switches, and it is computed as
the number of true positives (TP) that differ between tracking prediction and ground truth.
Expand Down
11 changes: 10 additions & 1 deletion python-sdk/nuscenes/panoptic/generate_panoptic_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from tqdm import tqdm

from nuscenes.nuscenes import NuScenes
from nuscenes.panoptic.panoptic_utils import STUFF_START_CLASS_ID
from nuscenes.utils.data_classes import LidarSegPointCloud
from nuscenes.utils.geometry_utils import points_in_box

Expand Down Expand Up @@ -70,7 +71,15 @@ def generate_panoptic_labels(nusc: NuScenes, out_dir: str, verbose: bool = False
panop_labels[indices[index]] += instance_id
overlap_box_count[indices[index]] += 1

panop_labels[overlap_box_count > 1] = 0
panop_labels[overlap_box_count > 1] = 0 # Set pixels overlapped by > 1 boxes to 0.

# Thing pixels that are not inside any box have instance id == 0, reset them to 0.
# For these pixels that have thing semantic classes, but do not fall inside any annotation box, set their
# panoptic label to 0.
semantic_labels = panop_labels // 1000
thing_mask = np.logical_and(semantic_labels > 0, semantic_labels < STUFF_START_CLASS_ID)
pixels_wo_box = np.logical_and(thing_mask, panop_labels % 1000 == 0)
panop_labels[pixels_wo_box] = 0

panoptic_file = nusc.get('lidarseg', lidar_token)['filename'].split('/')[-1]
panoptic_file = panoptic_file.replace('lidarseg', 'panoptic')
Expand Down

0 comments on commit 84ee1f3

Please sign in to comment.