tum-traffic-dataset / tum-traffic-dataset-dev-kit

TUM Traffic Dataset Development Kit
https://innovation-mobility.com/tumtraf-dataset
MIT License
43 stars 7 forks source link

Label Conversion error of OpenLABEL to nuS #9

Open Mike-7777777 opened 5 months ago

Mike-7777777 commented 5 months ago
Traceback (most recent call last):
  File "tum-traffic-dataset-dev-kit/src/label_conversion/conversion_openlabel_to_nuscenes.py", line 274, in <module>
    converter.convert_openlabel_to_nuscenes()
  File "tum-traffic-dataset-dev-kit/src/label_conversion/conversion_openlabel_to_nuscenes.py", line 88, in convert_openlabel_to_nuscenes
    infos_list += self._fill_infos(labels_list, camera_labels_list)
  File "tum-traffic-dataset-dev-kit/src/label_conversion/conversion_openlabel_to_nuscenes.py", line 158, in _fill_infos
    cam_annotations = [next(iter(json.load(open(camera_labels_list[0][j]))['openlabel']['frames'].values())) \
IndexError: list index out of range

Code related to this error is(I think):

camera_labels_list = []
for camera_list in sorted(glob(os.path.join(self.load_dir, self.map_version_to_dir[split], 'labels_images',
                                                        '*'))):
    camera_labels_list.append(sorted(glob(os.path.join(camera_list, '*'))))

When I print the camera_labels_list, it shows empty:

Start converting ...
Converting split: training...
[]
PaulBigiel commented 3 months ago

What I did to get the list non empty: The folder structure after the split is

However, in the code line 72 you find: for camera_list in sorted(glob(os.path.join(self.load_dir, self.map_version_to_dir[split], 'labels_images',

So the code searches for "labels_images", which doesn't exist but there is "labels_point_cloud". Change the code there to for camera_list in sorted(glob(os.path.join(self.load_dir, self.map_version_to_dir[split], 'labels_point_clouds', and the list won't be empty anymore.

You can clearly see that they changed their project structure, since the documentation also doesn't match directories for several scripts. I think it ran on their PC before they changed it and therefore maybe all bugs in the code are related to changed directory names.

Next error python gives me after changing the code: line 174, in _fill_infos cam_info['filename'] = os.path.join(cam_annotations[i]['frame_properties']['image_file_name']) KeyError: 'image_file_name'

I will look into it. Please let me know if you found a solution.

PaulBigiel commented 3 months ago

If you look into the JSON, you can see that there is no entry called image_file_name. However, there is image_file_names, which contains two immage names.

For example: 'image_file_names': ['1646667310_044372291_s110_camera_basler_south1_8mm.jpg', '1646667310_055996268_s110_camera_basler_south2_8mm.jpg']

You can replace

cam_info['filename'] = os.path.join(cam_annotations[i]['frame_properties']['image_file_name']) with cam_info['filename'] = os.path.join(cam_annotations[i]['frame_properties']['image_file_names'])

however, this will return a list instead of just an image file name, which gives you the following error: a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not list

It seems like the code is written for a dataset with one camera, however the default dataset the code links for if you give no arguments, cleary mentions the R02 dataset. default='/data/00_tum_traffic_dataset/r02_tum_traffic_intersection_dataset/r02_tum_traffic_intersection_dataset_train_val_test/',

This is really messed up.

PaulBigiel commented 3 months ago

Ok, the converter, once it works, doesn't make a dataset like nuscenes, but instead directly generates the corresponding .pkl files that are probably ment for use in mmdetection3D.

However, I think the BEV-Fusion repo has modified the way .pkl files are generated so they may not work as intended. I think I won't look further in this.