nutonomy / nuscenes-devkit

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

problems using export_kitti.py #1021

Closed RashoAli closed 5 months ago

RashoAli commented 6 months ago

i am trying to convert KITTI tracking dataset to the Nuscenes dataset format using the provided script in "python-sdk/nuscenes/scripts/export_kitti.py" unfortunatly it is not working for me. i am not sour what is the correct parametrs: nusc_kitti_dir: str = '/KITTI', cam_name: str = 'CAM_FRONT', lidar_name: str = 'LIDAR_TOP', image_count: int = 10, nusc_version: str = 'v1.0-mini', split: str = 'training'

is there any example code that i can use? or alredy converted KITTI data to Nuscenes dataset format?

whyekit-motional commented 6 months ago

@RashoAli pls show the error / traceback

RashoAli commented 6 months ago

v1.0-mini

Loading NuScenes tables for version v1.0-mini... 23 category, 8 attribute, 4 visibility, 911 instance, 12 sensor, 120 calibrated_sensor, 31206 ego_pose, 8 log, 10 scene, 404 sample, 31206 sample_data, 18538 sample_annotation, 4 map, Done loading in 0.383 seconds.

Reverse indexing ... Traceback (most recent call last): File "/media/rasho/Data 1/Arbeit/python_codes/World_space_tracking/StreamPETR/temp_python.py", line 368, in KC.kitti_res_to_nuscenes() File "/media/rasho/Data 1/Arbeit/python_codes/World_space_tracking/StreamPETR/temp_python.py", line 298, in kitti_res_to_nuscenes split_logs = create_splits_logs(self.split, self.nusc) File "/home/rasho/anaconda3/envs/streampetr/lib/python3.8/site-packages/nuscenes/utils/splits.py", line 163, in create_splits_logs assert split in scene_splits.keys(), 'Requested split {} which is not a known nuScenes split.'.format(split) AssertionError: Requested split training which is not a known nuScenes split. Done reverse indexing in 0.1 seconds.

Process finished with exit code 1

RashoAli commented 6 months ago

i have thefolowing folder structer

KITTI --maps
--render
--samples
--sweeps
--testing
--training
--v1.0-mini

where testing and training folders are from KITTI while the others are from NuScenes i am using the flowing code:

if __name__ == '__main__':
    # fire.Fire(KittiConverter)
    KC = KittiConverter()
    KC.kitti_res_to_nuscenes()
whyekit-motional commented 6 months ago

@RashoAli since you are using v1.0-mini, I think - for the split param - you should use mini_train instead of training

(If you want to operate on the full train set, then try split=train and nusc_version=v1.0-trainval - pls see here for details)

RashoAli commented 6 months ago

when i use "mini_train" i get the folowing error: FileNotFoundError: [Errno 2] No such file or directory: 'dataset/KITTI/mini_train/image_2'

So my question is should i change the folder names?

and another question: Since i want to convert the KITTI dataset format to the nusc dataset format why should i have the nusc installed? dont i just need only KITTI dataset?

whyekit-motional commented 6 months ago

@RashoAli yes, I think you should change the folder name since the directory is determined by the value passed into split: https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/utils/kitti.py#L61

As to why you should have nuscenes-devkit installed even though you just want to convert the KITTI data to nuScenes format: this is because nuscenes-devkit provides a wrapper (KittiDB) to load the KITTI data and perform the conversion :smile:

RashoAli commented 6 months ago

@whyekit-motional i changed the folder names to the following: KITTI |--maps |--render |--samples |--sweeps |--test |--train |--v1.0-mini

and in the code:

class KittiConverter:
    def __init__(self,
                 nusc_kitti_dir: str = '/KITTI',
                 cam_name: str = 'CAM_FRONT',
                 lidar_name: str = 'LIDAR_TOP',
                 image_count: int = 10,
                 nusc_version: str = 'v1.0-trainval',
                 split: str = 'train'):

still i am getting an error regarding AssertionError: Database version not found: /KITTI/v1.0-trainval

This goes back to my previous question, which I believe I wasn't clear in formulating 😄 : If I want to convert KITTI dataset from the KITTI format to the nuScenes format, why is the code asking me for the nuScenes dataset? How can I resolve this issue?

whyekit-motional commented 6 months ago

@RashoAli I think what might be happening here is that kitti_res_to_nuscenes operates on nuScenes data in KITTI format, not KITTI data itself, since the sample tokens are coming from nuScenes: https://github.com/nutonomy/nuscenes-devkit/blob/9b165b1018a64623b65c17b64f3c9dd746040f36/python-sdk/nuscenes/scripts/export_kitti.py#L296

RashoAli commented 6 months ago

@whyekit-motional dose that means that export_kitti.pycan not change KITTI dataset to the NuSce_dataset format? if yes do you know of any other alternatives?

whyekit-motional commented 6 months ago

@RashoAli you could try changing these lines of code: https://github.com/nutonomy/nuscenes-devkit/blob/9b165b1018a64623b65c17b64f3c9dd746040f36/python-sdk/nuscenes/scripts/export_kitti.py#L296-L300

To:

sample_tokens = kitti.tokens[:self.image_count]

And then point the split param to your KITTI train folder

I'm not 100% sure if it will work, but you could give it a shot