## Annotations my_annotation = lyftdata.get('sample_annotation', my_sample['anns'][0]) my_box = lyftdata.get_box(my_annotation['token']) lyftdata.render_annotation(my_annotation['token'], margin=10) ## Attributes my_attribute1 = lyftdata.get('attribute', my_annotation['attribute_tokens'][0]) my_attribute2 = lyftdata.get('attribute', my_annotation['attribute_tokens'][1]) ## Instances my_instance = lyftdata.get('instance', my_annotation['instance_token']) lyftdata.render_instance(my_instance['token']) print("First annotated sample of this instance:") lyftdata.render_annotation(my_instance['first_annotation_token']) print("Last annotated sample of this instance") lyftdata.render_annotation(my_instance['last_annotation_token']) lyftdata.render_sample(token0) ## 3D visualization of a scene ## Be sure to make a folder named tmp in data_path my_scene = lyftdata.get('scene', my_sample['scene_token']) first_sample_token = my_scene['first_sample_token'] sample = lyftdata.get('sample', first_sample_token) lidar_token = sample['data']['LIDAR_TOP'] filename = draw_3d_plot(0, lidar_token) Image.open(filename)
import numpy as np button = cfg.data.button lyft_data = LyftDataset(data_path=cfg.data.lyft, json_path=cfg.data.train_path, verbose=False) if button.LIST_SCENE: lyft_data.list_scenes() if button.LIST_CATEG: lyft_data.list_categories() one_scene = lyft_data.scene[0] first_sample_token = one_scene["first_sample_token"] end_sample_token = one_scene["last_sample_token"] if button.REND_SAMPLE: lyft_data.render_sample(first_sample_token, out_path="./data/01") lyft_data.render_sample(end_sample_token, out_path="./data/02") # Sample sample = lyft_data.get('sample', first_sample_token) # print("sample keys are, ", sample.keys()) print('list sample in the first sample token') if button.LIST_SAMPLE: lyft_data.list_sample(sample['token']) if button.REND_PC_IMG: lyft_data.render_pointcloud_in_image(sample_token=sample["token"], dot_size=1, pointsensor_channel='LIDAR_TOP', camera_channel='CAM_FRONT', out_path="./data/03") # Sample lidar in 3d