Skip to content

fix(nuscenes): ensure self.scene is set when NuScenes (+3 more) - #32

Open
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/nuscenes-assorted-0c73228b
Open

fix(nuscenes): ensure self.scene is set when NuScenes (+3 more)#32
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/nuscenes-assorted-0c73228b

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 27, 2026

Copy link
Copy Markdown

Small fixes in datasets/nuscenes.py:

fix: ensure self.scene is set when NuScenes handle is passed in

Fix: Replace:

        if self.nusc is None:
            self.nusc = NuScenes(
                version="v1.0-trainval", dataroot=self.data_path, verbose=True
            )
            self.scene = self.nusc.scene[self.scene_idx]
        total_camera_list = [

with:

        if self.nusc is None:
            self.nusc = NuScenes(
                version="v1.0-trainval", dataroot=self.data_path, verbose=True
            )
        self.scene = self.nusc.scene[self.scene_idx]
        total_camera_list = [

fix: truncate lidar rays by Euclidean range, not world x coordinate

Fix: Replace:

            valid_mask = torch.ones_like(lidar_origins[:, 0]).bool()
            if self.data_cfg.truncated_max_range is not None:
                valid_mask = lidar_points[:, 0] < self.data_cfg.truncated_max_range
            if self.data_cfg.truncated_min_range is not None:
                valid_mask = valid_mask & (
                    lidar_points[:, 0] > self.data_cfg.truncated_min_range
                )

with:

            valid_mask = torch.ones_like(lidar_origins[:, 0]).bool()
            if self.data_cfg.truncated_max_range is not None:
                valid_mask = lidar_ranges.squeeze(-1) < self.data_cfg.truncated_max_range
            if self.data_cfg.truncated_min_range is not None:
                valid_mask = valid_mask & (
                    lidar_ranges.squeeze(-1) > self.data_cfg.truncated_min_range
                )

fix: clamp normalized feature colors to [0,1] after division

Fix: Replace:

                features = (features - self.pixel_source.feat_color_min) / (
                    self.pixel_source.feat_color_max - self.pixel_source.feat_color_min
                ).clamp(0, 1)

with:

                features = ((features - self.pixel_source.feat_color_min) / (
                    self.pixel_source.feat_color_max - self.pixel_source.feat_color_min
                )).clamp(0, 1)

fix: count original lidar rays before remove_close filtering

Fix: Replace:

            lidar_pc = LidarPointCloud.from_file(self.lidar_filepaths[t])
            lidar_pc.remove_close(1.0)
            pc = lidar_pc.points[:3, :].T
            pc = np.hstack((pc, np.ones((pc.shape[0], 1))))
            pc = torch.from_numpy(pc).float()
            lidar_points = pc @ self.lidar_to_worlds[t].T
            lidar_points = lidar_points[:, :3]
            lidar_origins = (
                self.lidar_to_worlds[t][:3, 3]
                .unsqueeze(0)
                .repeat(lidar_points.shape[0], 1)
            )
            lidar_directions = lidar_points - lidar_origins
            lidar_ranges = torch.norm(lidar_directions, dim=-1, keepdim=True)
            lidar_directions = lidar_directions / lidar_ranges
            accumulated_num_original_rays += len(lidar_pc.points[0])

with:

            lidar_pc = LidarPointCloud.from_file(self.lidar_filepaths[t])
            accumulated_num_original_rays += len(lidar_pc.points[0])
            lidar_pc.remove_close(1.0)
            pc = lidar_pc.points[:3, :].T
            pc = np.hstack((pc, np.ones((pc.shape[0], 1))))
            pc = torch.from_numpy(pc).float()
            lidar_points = pc @ self.lidar_to_worlds[t].T
            lidar_points = lidar_points[:, :3]
            lidar_origins = (
                self.lidar_to_worlds[t][:3, 3]
                .unsqueeze(0)
                .repeat(lidar_points.shape[0], 1)
            )
            lidar_directions = lidar_points - lidar_origins
            lidar_ranges = torch.norm(lidar_directions, dim=-1, keepdim=True)
            lidar_directions = lidar_directions / lidar_ranges

Files changed

  • datasets/nuscenes.py

@andrewwhitecdw
andrewwhitecdw marked this pull request as ready for review August 3, 2026 22:09
@andrewwhitecdw

Copy link
Copy Markdown
Author

Closing this sweep-generated PR: sole commit is missing a valid Signed-off-by trailer. It does not meet the sweep requirements (single signed-off commit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant