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_detectionThe format specification is available inREADME.mdhere. - Segmentation -
kitti_segmentationThe format specification is available inREADME.mdhere. - 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 object
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 create
datum import --format kitti <path/to/dataset>
It is possible to specify project name and project directory. Run
datum create --help for more information.
KITTI segmentation dataset directory should have the following structure:
└─ Dataset/
├── 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
└── ...
You can import a dataset for specific tasks of KITTI dataset instead of the whole dataset, for example:
datum 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 create
datum import -f kitti <path/to/kitti>
datum export -f cityscapes -o <output/dir>
# or
datum convert -if kitti -i <path/to/kitti> -f cityscapes -o <output/dir>
Or, using Python API:
from datumaro.components.dataset import Dataset
dataset = Dataset.import_from('<path/to/dataset>', 'kitti')
dataset.export('save_dir', 'cityscapes', save_images=True)
Export to KITTI
There are several ways to convert a dataset to KITTI format:
# export dataset into KITTI format from existing project
datum export -p <path/to/project> -f kitti -o <output/dir> \
-- --save-images
# converting to KITTI format from other format
datum convert -if cityscapes -i <path/to/dataset> \
-f kitti -o <output/dir> -- --save-images
Extra options for exporting to KITTI format:
--save-imagesallow to export dataset with saving images (by defaultFalse)--image-ext IMAGE_EXTallow to specify image extension for exporting dataset (by default - keep original or use.png, if none)--apply-colormap APPLY_COLORMAPallow to use colormap for class masks (in foldersemantic_rgb, by defaultTrue)--label_mapallow to define a custom colormap. Example:
# mycolormap.txt :
# 0 0 255 sky
# 255 0 0 person
#...
datum export -f kitti -- --label-map mycolormap.txt
# or you can use original kitti colomap:
datum export -f kitti -- --label-map kitti
--tasks TASKSallow to specify tasks for export dataset, by default Datumaro uses all tasks. Example:
datum export -f kitti -- --tasks detection
--allow-attributes ALLOW_ATTRIBUTESallow 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 create -o project
datum import -p project -f kitti ./KITTI/
datum stats -p project
datum export -p project -f cityscapes -- --save-images
Example 2. How to create a custom KITTI-like dataset
import numpy as np
from datumaro.components.annotation import Mask
from datumaro.components.dataset import Dataset
from datumaro.components.extractor import DatasetItem
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 = Dataset.from_iterable([
DatasetItem(id=1,
image=np.ones((1, 5, 3)),
annotations=[
Mask(image=np.array([[1, 0, 0, 1, 1]]), label=1, id=0,
attributes={'is_crowd': False}),
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