KITTI#
Format specification#
The KITTI dataset has many annotations for different tasks. Datumaro supports only a few of them.
Supported tasks / formats:
Object Detection -
kitti_detection
The format specification is available inREADME.md
here.Segmentation -
kitti_segmentation
The format specification is available inREADME.md
here.Raw 3D / Velodyne Points - described here
Supported annotation types:
Bbox
(object detection)Mask
(segmentation)
Supported annotation attributes:
truncated
(boolean) - indicates that the bounding box specified for the object does not correspond to the full extent of the objectoccluded
(boolean) - indicates that a significant portion of the object within the bounding box is occluded by another objectscore
(float) - indicates confidence in detection
Import KITTI dataset#
The KITTI left color images for object detection are available here. The KITTI object detection labels are available here. The KITTI segmentation dataset is available here.
A Datumaro project with a KITTI source can be created in the following way:
datum project create
datum project import --format kitti <path/to/dataset>
It is possible to specify project name and project directory. Run
datum project create --help
for more information.
KITTI detection dataset directory should have the following structure:
└─ Dataset/
├── testing/
│ └── image_2/
│ ├── <name_1>.<img_ext>
│ ├── <name_2>.<img_ext>
│ └── ...
└── training/
├── image_2/ # left color camera images
│ ├── <name_1>.<img_ext>
│ ├── <name_2>.<img_ext>
│ └── ...
└─── label_2/ # left color camera label files
├── <name_1>.txt
├── <name_2>.txt
└── ...
KITTI segmentation dataset directory should have the following structure:
└─ Dataset/
├── dataset_meta.json # a list of non-format labels (optional)
├── label_colors.txt # optional, color map for non-original segmentation labels
├── testing/
│ └── image_2/
│ ├── <name_1>.<img_ext>
│ ├── <name_2>.<img_ext>
│ └── ...
└── training/
├── image_2/ # left color camera images
│ ├── <name_1>.<img_ext>
│ ├── <name_2>.<img_ext>
│ └── ...
├── label_2/ # left color camera label files
│ ├── <name_1>.txt
│ ├── <name_2>.txt
│ └── ...
├── instance/ # instance segmentation masks
│ ├── <name_1>.png
│ ├── <name_2>.png
│ └── ...
├── semantic/ # semantic segmentation masks (labels are encoded by its id)
│ ├── <name_1>.png
│ ├── <name_2>.png
│ └── ...
└── semantic_rgb/ # semantic segmentation masks (labels are encoded by its color)
├── <name_1>.png
├── <name_2>.png
└── ...
To add custom classes, you can use dataset_meta.json
and label_colors.txt
.
If the dataset_meta.json
is not represented in the dataset, then
label_colors.txt
will be imported if possible.
You can import a dataset for specific tasks of KITTI dataset instead of the whole dataset, for example:
datum project import --format kitti_detection <path/to/dataset>
To make sure that the selected dataset has been added to the project, you can
run datum project info
, which will display the project information.
Export to other formats#
Datumaro can convert a KITTI dataset into any other format Datumaro supports.
Such conversion will only be successful if the output
format can represent the type of dataset you want to convert,
e.g. segmentation annotations can be
saved in Cityscapes
format, but not as COCO keypoints
.
There are several ways to convert a KITTI dataset to other dataset formats:
datum project create
datum project import -f kitti <path/to/kitti>
datum project export -f cityscapes -o <output/dir>
or
datum convert -if kitti -i <path/to/kitti> -f cityscapes -o <output/dir>
Or, using Python API:
import datumaro as dm
dataset = dm.Dataset.import_from('<path/to/dataset>', 'kitti')
dataset.export('save_dir', 'cityscapes', save_media=True)
Export to KITTI#
There are several ways to convert a dataset to KITTI format:
# export dataset into KITTI format from existing project
datum project export -p <path/to/project> -f kitti -o <output/dir> \
-- --save-media
# converting to KITTI format from other format
datum convert -if cityscapes -i <path/to/dataset> \
-f kitti -o <output/dir> -- --save-media
Extra options for exporting to KITTI format:
--save-media
allow to export dataset with saving media files (by defaultFalse
)--image-ext IMAGE_EXT
allow to specify image extension for exporting dataset (by default - keep original or use.png
, if none)--save-dataset-meta
- allow to export dataset with saving dataset meta file (by defaultFalse
)--apply-colormap APPLY_COLORMAP
allow to use colormap for class masks (in foldersemantic_rgb
, by defaultTrue
)--label_map
allow to define a custom colormap. Example:
# mycolormap.txt :
# 0 0 255 sky
# 255 0 0 person
#...
datum project export -f kitti -- --label-map mycolormap.txt
or you can use original kitti colormap:
datum project export -f kitti -- --label-map kitti
--tasks TASKS
allow to specify tasks for export dataset, by default Datumaro uses all tasks. Example:
datum project export -f kitti -- --tasks detection
--allow-attributes ALLOW_ATTRIBUTES
allow export of attributes (by defaultTrue
).
Examples#
Datumaro supports filtering, transformation, merging etc. for all formats and for the KITTI format in particular. Follow the user manual to get more information about these operations.
There are several examples of using Datumaro operations to solve particular problems with KITTI dataset:
Example 1. How to load an original KITTI dataset and convert to Cityscapes#
datum project create -o project
datum project import -p project -f kitti ./KITTI/
datum stats -p project
datum project export -p project -f cityscapes -- --save-media
Example 2. How to create a custom KITTI-like dataset#
import numpy as np
import datumaro as dm
import datumaro.plugins.kitti_format as KITTI
label_map = {}
label_map['background'] = (0, 0, 0)
label_map['label_1'] = (1, 2, 3)
label_map['label_2'] = (3, 2, 1)
categories = KITTI.make_kitti_categories(label_map)
dataset = dm.Dataset.from_iterable([
dm.DatasetItem(id=1,
image=np.ones((1, 5, 3)),
annotations=[
dm.Mask(image=np.array([[1, 0, 0, 1, 1]]), label=1, id=0,
attributes={'is_crowd': False}),
dm.Mask(image=np.array([[0, 1, 1, 0, 0]]), label=2, id=0,
attributes={'is_crowd': False}),
]
),
], categories=categories)
dataset.export('./dataset', format='kitti')
Examples of using this format from the code can be found in the format tests