nutonomy / nuscenes-devkit

The devkit of the nuScenes dataset.
https://www.nuScenes.org
Other
2.19k stars 616 forks source link

Part number with debris annotation #1020

Closed shawrby closed 5 months ago

shawrby commented 6 months ago

Hi,

I'm currently researching debris detection on driving roads.

Could you know me which download part numbers contains debris annotations?

Thanks in advance.

whyekit-motional commented 6 months ago

@shawrby you could use something like this to retrieve all the scenes that contain at least one movable_object.debris object:

from tqdm import tqdm 

from nuscenes.nuscenes import NuScenes

nusc = NuScenes(version='v1.0-mini', dataroot='/data/sets/nuscenes', verbose=False)

scene_tokens = set()
for sample in tqdm(nusc.sample):
    scene_token = sample['scene_token']

    for ann_token in sample['anns']:
        ann = nusc.get('sample_annotation', ann_token)
        category_name = ann['category_name'] 

        if category_name == 'movable_object.debris':
            scene_tokens.add(scene_token)
            break

scene_names = list()
for scene_token in scene_tokens:
    scene = nusc.get('scene', scene_token)
    scene_names.append(scene['name'])
assert len(scene_names) == len(scene_tokens)

print(scene_names)

Once you have the scene names, you can figure out which blobs they belong to using the code snippet here: https://github.com/nutonomy/nuscenes-devkit/issues/980#issuecomment-1715566828