raillabel_providerkit package

Subpackages

Submodules

raillabel_providerkit.exceptions module

Module contents

A library for annotation providers of raillabel-formatted data.

raillabel_providerkit.convert(data: dict, loader_class: type[LoaderABC] | None = None) Scene

Convert annotation data from provider formats into raillabel.

Parameters:
  • data (dict) – Raw data in the provider format, that should be converted.

  • loader_class (child-class of raillabel_providerkit.LoaderABC, optional) – Class used for converting the provider formatted data. If None is provided, then one is chosen based on criteria present in the data. Default is None.

Returns:

scene – Scene with the loaded data in the raillabel format.

Return type:

raillabel.Scene

Raises:

raillabel.UnsupportedFormatError – if the annotation file does not match any loaders.

raillabel_providerkit.export_scenes(input_folder: Path, output_folder: Path, formats: list[Literal['json', 'csv']] | None = None, quiet: bool = False) dict[str, int]

Export multiple scenes from a folder to different formats.

Parameters:
  • input_folder (Path) – Folder containing scene JSON files to export

  • output_folder (Path) – Folder where exported files will be saved

  • formats (list[ExportFormat] | None, optional) – List of formats to export to. Can contain ‘json’, ‘csv’, or both. If None, defaults to [‘json’].

  • quiet (bool, optional) – If True, disables progress bars. Default is False.

Returns:

Dictionary with export statistics: - ‘total’: Total number of scenes found - ‘exported’: Number of successfully exported scenes - ‘errors’: Number of scenes that failed to export

Return type:

dict[str, int]

Raises:
raillabel_providerkit.get_ontology_path(ontology_name: str) Path

Get the path to a built-in ontology file.

Parameters:

ontology_name (str) – Name of the ontology to load. Supported values: - “osdar26”: Extended railway environment ontology (25 classes) - “automatedtrain”: Safety-critical classes for automated train operation - “osdar23”: Original OSDAR23 dataset ontology

Returns:

Path to the ontology YAML file (located in config/ontologies/)

Return type:

Path

Raises:

ValueError – If the ontology name is not recognized

raillabel_providerkit.get_schema_path(schema_name: str) Path

Get the path to a built-in schema file.

Parameters:

schema_name (str) – Name of the schema to load. Supported values: - “raillabel”: Generic RailLabel JSON schema (OpenLABEL subset) - “osdar23”: OSDAR23-specific RailLabel schema - “osdar26”: OSDAR26-specific RailLabel schema - “automatedtrain”: AutomatedTrain-specific RailLabel schema - “understand_ai_t4”: Understand.AI T4 format schema - “ontology”: Ontology validation schema (v2)

Returns:

Path to the schema file (located in config/schemas/)

Return type:

Path

Raises:

ValueError – If the schema name is not recognized

Notes

The ontology-specific schemas (osdar23, osdar26, automatedtrain) are currently identical copies of the base raillabel schema, as they share the same OpenLABEL structure. Ontology-specific validation is handled by the ontology YAML files.

raillabel_providerkit.list_available_ontologies() list[str]

List all available built-in ontologies.

Returns:

List of available ontology names

Return type:

list[str]

raillabel_providerkit.list_available_schemas() list[str]

List all available built-in schemas.

Returns:

List of available schema names

Return type:

list[str]

raillabel_providerkit.validate(scene_source: dict | Path, ontology_source: dict | Path | None = None, validate_for_empty_frames: bool = True, validate_for_rail_side_order: bool = True, validate_for_missing_ego_track: bool = True, validate_for_ego_track_both_rails: bool = True, validate_for_sensors: bool = True, validate_for_uris: bool = True, validate_for_dimensions: bool = True, validate_for_horizon: bool = True, validate_for_annotation_type_per_sensor: bool = True, validate_for_transition: bool = True, horizon_tolerance_percent: float = 10.0) list[Issue]

Validate a scene based on the Deutsche Bahn Requirements.

Args:

scene_source: The scene either as a dictionary or as a Path to the scene source file. ontology_source: The dataset ontology as a dictionary or as a Path to the ontology YAML

file. If not None, issues are returned if the scene contains annotations with invalid attributes or object types. Default is None.

validate_for_empty_frames (optional): If True, issues are returned if the scene contains

sensor frames without annotations. Only checks middle/center cameras and lidar sensors. Default is True.

validate_for_rail_side_order: If True, issues are returned if the scene contains track with

a mismatching rail side order. Default is True.

validate_for_missing_ego_track: If True, issues are returned if the scene contains frames

where the ego track (the track the recording train is driving on) is missing. Checks both middle/center cameras and lidar sensors. Default is True.

validate_for_ego_track_both_rails: If True, issues are returned if the ego track rails

don’t have overlapping y-ranges or don’t have exactly one left and one right rail. Default is True.

validate_for_sensors: If True, issues are returned if the scene contains sensors that are

not supported or have the wrong sensor type.

validate_for_uris: If True, issues are returned if the uri fields in the scene contain

unsupported values.

validate_for_dimensions: If True, issues are returned if the dimensions of cuboids are

outside the expected values range.

validate_for_horizon: If True, issues are returned if annotations cross the horizon. validate_for_annotation_type_per_sensor: Validate that annotation types match sensor types. validate_for_transition: If True, issues are returned if transition annotations have

identical startTrack and endTrack values. Default is True.

horizon_tolerance_percent: Tolerance buffer as percentage above the horizon line.

Annotations within this buffer zone are considered valid. For example, 10.0 means annotations up to 10% above the horizon line are accepted. Default is 10.0 (10% buffer). This only affects track and transition annotations.

Returns:

List of all requirement errors in the scene. If an empty list is returned, then there are no errors present and the scene is valid.