detectionmetrics.datasets package
Submodules
detectionmetrics.datasets.dataset module
- class detectionmetrics.datasets.dataset.ImageSegmentationDataset(dataset: DataFrame, dataset_dir: str, ontology: dict, is_label_rgb: bool = False)
Bases:
SegmentationDataset
Parent image segmentation dataset class
- Parameters:
dataset (pd.DataFrame) – Image segmentation dataset as a pandas DataFrame
dataset_dir (str) – Dataset root directory
ontology (dict) – Dataset ontology definition
is_label_rgb (bool, optional) – Whether the labels are in RGB format or not, defaults to False
- export(outdir: str, new_ontology: dict | None = None, ontology_translation: dict | None = None, ignored_classes: List[str] | None = None, resize: Tuple[int, int] | None = None, include_label_count: bool = True)
Export dataset dataframe and image files in SemanticKITTI format. Optionally, modify ontology before exporting.
- Parameters:
outdir (str) – Directory where Parquet and images files will be stored
new_ontology (dict) – Target ontology definition
ontology_translation (Optional[dict], optional) – Ontology translation dictionary, defaults to None
ignored_classes (Optional[List[str]], optional) – Classes to ignore from the old ontology, defaults to []
resize (Optional[Tuple[int, int]], optional) – Resize images and labels to the given dimensions, defaults to None
include_label_count (bool, optional) – Whether to include class weights in the dataset, defaults to True
- get_label_count(splits: List[str] | None = None)
Get label count for each class in the dataset
- Parameters:
splits (List[str], optional) – Dataset splits to consider, defaults to [“train”, “val”]
- Returns:
Label count for the dataset
- Return type:
np.ndarray
- make_fname_global()
Get all relative filenames in dataset and make global
- read_label(fname: str) ndarray
Read label from an image file
- Parameters:
fname (str) – Image file containing labels
- Returns:
Numpy array containing labels
- Return type:
np.ndarray
- class detectionmetrics.datasets.dataset.LiDARSegmentationDataset(dataset: DataFrame, dataset_dir: str, ontology: dict, is_kitti_format: bool = True)
Bases:
SegmentationDataset
Parent lidar segmentation dataset class
- Parameters:
dataset (pd.DataFrame) – LiDAR segmentation dataset as a pandas DataFrame
dataset_dir (str) – Dataset root directory
ontology (dict) – Dataset ontology definition
is_kitti_format (bool, optional) – Whether the linked files in the dataset are stored in SemanticKITTI format or not, defaults to True
- export(outdir: str, new_ontology: dict | None = None, ontology_translation: dict | None = None, ignored_classes: List[str] | None = [])
Export dataset dataframe and LiDAR files in SemanticKITTI format. Optionally, modify ontology before exporting.
- Parameters:
outdir (str) – Directory where Parquet and LiDAR files will be stored
new_ontology (dict) – Target ontology definition
ontology_translation (Optional[dict], optional) – Ontology translation dictionary, defaults to None
ignored_classes (Optional[List[str]], optional) – Classes to ignore from the old ontology, defaults to []
- make_fname_global()
Get all relative filenames in dataset and make global
- static read_label(fname: str) Tuple[ndarray, ndarray]
Read labels from a binary file in SemanticKITTI format
- Parameters:
fname (str) – Binary file containing labels
- Returns:
Numpy arrays containing semantic and instance labels
- Return type:
Tuple[np.ndarray, np.ndarray]
- static read_points(fname: str) ndarray
Read points from a binary file in SemanticKITTI format
- Parameters:
fname (str) – Binary file containing points
- Returns:
Numpy array containing points
- Return type:
np.ndarray
- class detectionmetrics.datasets.dataset.SegmentationDataset(dataset: DataFrame, dataset_dir: str, ontology: dict)
Bases:
ABC
Abstract segmentation dataset class
- Parameters:
dataset (pd.DataFrame) – Segmentation dataset as a pandas DataFrame
dataset_dir (str) – Dataset root directory
ontology (dict) – Dataset ontology definition
- append(new_dataset: Self)
Append another dataset with common ontology
- Parameters:
new_dataset (Self) – Dataset to be appended
- get_label_count(splits: List[str] | None = None)
Get label count for each class in the dataset
- Parameters:
splits (List[str], optional) – Dataset splits to consider, defaults to [“train”, “val”]
- Returns:
Label count for the dataset
- Return type:
np.ndarray
- abstract make_fname_global()
Get all relative filenames in dataset and make global
detectionmetrics.datasets.gaia module
- class detectionmetrics.datasets.gaia.GaiaImageSegmentationDataset(dataset_fname: str)
Bases:
ImageSegmentationDataset
Specific class for GAIA-styled image segmentation datasets
- Parameters:
dataset_fname (str) – Parquet dataset filename
- class detectionmetrics.datasets.gaia.GaiaLiDARSegmentationDataset(dataset_fname: str)
Bases:
LiDARSegmentationDataset
Specific class for GAIA-styled LiDAR segmentation datasets
- Parameters:
dataset_fname (str) – Parquet dataset filename
- detectionmetrics.datasets.gaia.build_dataset(dataset_fname: str) Tuple[DataFrame, str, dict]
Build dataset and ontology dictionaries from GAIA-like dataset structure
- Parameters:
dataset_fname (str) – Parquet dataset filename
- Returns:
Dataset dataframe and directory, and onotology
- Return type:
Tuple[pd.DataFrame, str, dict]
detectionmetrics.datasets.goose module
- class detectionmetrics.datasets.goose.GOOSEImageSegmentationDataset(train_dataset_dir: str | None = None, val_dataset_dir: str | None = None, test_dataset_dir: str | None = None)
Bases:
ImageSegmentationDataset
Specific class for GOOSE-styled image segmentation datasets. All data can be downloaded from the official webpage (https://goose-dataset.de): train -> https://goose-dataset.de/storage/goose_2d_train.zip val -> https://goose-dataset.de/storage/goose_2d_val.zip test -> https://goose-dataset.de/storage/goose_2d_test.zip
- Parameters:
train_dataset_dir (str) – Directory containing training data
val_dataset_dir (str, optional) – Directory containing validation data, defaults to None
test_dataset_dir (str, optional) – Directory containing test data, defaults to None
- class detectionmetrics.datasets.goose.GOOSELiDARSegmentationDataset(train_dataset_dir: str | None = None, val_dataset_dir: str | None = None, test_dataset_dir: str | None = None)
Bases:
LiDARSegmentationDataset
Specific class for GOOSE-styled LiDAR segmentation datasets. All data can be downloaded from the official webpage (https://goose-dataset.de): train -> https://goose-dataset.de/storage/goose_3d_train.zip val -> https://goose-dataset.de/storage/goose_3d_val.zip test -> https://goose-dataset.de/storage/goose_3d_test.zip
- Parameters:
train_dataset_dir (str) – Directory containing training data
val_dataset_dir (str, optional) – Directory containing validation data, defaults to None
test_dataset_dir (str, optional) – Directory containing test data, defaults to None
- detectionmetrics.datasets.goose.build_dataset(data_type: str, data_suffix: str, label_suffix: str, train_dataset_dir: str | None = None, val_dataset_dir: str | None = None, test_dataset_dir: str | None = None) Tuple[dict, dict]
Build dataset and ontology dictionaries from GOOSE dataset structure
- Parameters:
train_dataset_dir (str) – Directory containing training data
data_type (str) – Data to be read (e.g. images or lidar)
data_suffix (str) – File suffix to be used to filter data (e.g., windshield_vis.png or vls128.bin)
label_suffix (str) – File suffix to be used to filter labels (e.g., vis_labelids.png or goose.label)
val_dataset_dir (str, optional) – Directory containing validation data, defaults to None
test_dataset_dir (str, optional) – Directory containing test data, defaults to None
- Returns:
Dataset and onotology
- Return type:
Tuple[dict, dict]
detectionmetrics.datasets.rellis3d module
- class detectionmetrics.datasets.rellis3d.Rellis3DImageSegmentationDataset(dataset_dir: str, split_dir: str, ontology_fname: str)
Bases:
ImageSegmentationDataset
Specific class for Rellis3D-styled image segmentation datasets. All data can be downloaded from the official repo (https://github.com/unmannedlab/RELLIS-3D): images -> https://drive.google.com/file/d/1F3Leu0H_m6aPVpZITragfreO_SGtL2yV labels -> https://drive.google.com/file/d/16URBUQn_VOGvUqfms-0I8HHKMtjPHsu5 split -> https://drive.google.com/file/d/1zHmnVaItcYJAWat3Yti1W_5Nfux194WQ ontology -> https://drive.google.com/file/d/1K8Zf0ju_xI5lnx3NTDLJpVTs59wmGPI6
- Parameters:
dataset_dir (str) – Directory where both RGB images and annotations have been extracted to
split_dir (str) – Directory where train, val, and test files (.lst) have been extracted to
ontology_fname (str) – YAML file contained in the ontology compressed directory
- class detectionmetrics.datasets.rellis3d.Rellis3DLiDARSegmentationDataset(dataset_dir: str, split_dir: str, ontology_fname: str)
Bases:
LiDARSegmentationDataset
Specific class for Rellis3D-styled LiDAR segmentation datasets. All data can be downloaded from the official repo (https://github.com/unmannedlab/RELLIS-3D): points -> https://drive.google.com/file/d/1lDSVRf_kZrD0zHHMsKJ0V1GN9QATR4wH labels -> https://drive.google.com/file/d/12bsblHXtob60KrjV7lGXUQTdC5PhV8Er split -> https://drive.google.com/file/d/1raQJPySyqDaHpc53KPnJVl3Bln6HlcVS ontology -> https://drive.google.com/file/d/1K8Zf0ju_xI5lnx3NTDLJpVTs59wmGPI6
- Parameters:
dataset_dir (str) – Directory where both points and labels have been extracted to
split_dir (str) – Directory where train, val, and test files (.lst) have been extracted to
ontology_fname (str) – YAML file contained in the ontology compressed directory
- detectionmetrics.datasets.rellis3d.build_dataset(dataset_dir: str, split_fnames: dict, ontology_fname: str) Tuple[dict, dict]
Build dataset and ontology dictionaries from Rellis3D dataset structure
- Parameters:
dataset_dir (str) – Directory where both RGB images and annotations have been extracted to
split_fnames – Dictionary that contains the paths where train, val, and test split files (.lst) have been extracted to
ontology_fname (str) – YAML file contained in the ontology compressed directory
- Returns:
Dataset and onotology
- Return type:
Tuple[dict, dict]