raillabel_providerkit.validation package

Subpackages

Submodules

raillabel_providerkit.validation.issue module

class raillabel_providerkit.validation.issue.Issue(type: IssueType, identifiers: IssueIdentifiers | list[str | int], reason: str | None = None)

Bases: object

An error that was found inside the scene.

classmethod deserialize(serialized_issue: dict[str, str | dict[str, str | int] | list[str | int]]) Issue

Deserialize a JSON-compatible dictionary back into an Issue class instance.

Parameters:

serialized_issue (dict[str, str | dict[str, str | int] | list[str | int]]) – The serialized Issue as a JSON-compatible dictionary

Returns:

The deserialized Issue class instance

Return type:

Issue

Raises:

jsonschema.exceptions.ValidationError – If the serialized data does not match the Issue JSONSchema.

identifiers: IssueIdentifiers | list[str | int]
reason: str | None = None
serialize() dict[str, str | dict[str, str | int] | list[str | int]]

Serialize the Issue into a JSON-compatible dictionary.

Returns:

The serialized Issue as a JSON-compatible dictionary

Return type:

dict[str, str | dict[str, str | int] | list[str | int]]

type: IssueType
class raillabel_providerkit.validation.issue.IssueIdentifiers(annotation: UUID | None = None, annotation_type: Literal['Bbox', 'Cuboid', 'Num', 'Poly2d', 'Poly3d', 'Seg3d'] | None = None, attribute: str | None = None, frame: int | None = None, object: UUID | None = None, object_type: str | None = None, sensor: str | None = None)

Bases: object

Information for locating an issue.

annotation: UUID | None = None
annotation_type: Literal['Bbox', 'Cuboid', 'Num', 'Poly2d', 'Poly3d', 'Seg3d'] | None = None
attribute: str | None = None
classmethod deserialize(serialized_identifiers: dict[str, str | int]) IssueIdentifiers

Deserialize a JSON-compatible dictionary back into an IssueIdentifiers class instance.

Parameters:

serialized_identifiers (dict[str, str | int]) – The serialized IssueIdentifiers as a JSON-compatible dictionary

Returns:

The deserialized IssueIdentifiers class instance

Return type:

IssueIdentifiers

Raises:

TypeError – If any of the fields have an unexpected type

frame: int | None = None
object: UUID | None = None
object_type: str | None = None
sensor: str | None = None
serialize() dict[str, str | int]

Serialize the IssueIdentifiers into a JSON-compatible dictionary.

Returns:

The serialized IssueIdentifiers as a JSON-compatible dictionary

Return type:

dict[str, str | int]

class raillabel_providerkit.validation.issue.IssueType(*values)

Bases: Enum

General classification of the issue.

ANNOTATION_SENSOR_MISMATCH = 'AnnotationSensorMismatch'
ATTRIBUTE_MISSING = 'AttributeMissing'
ATTRIBUTE_SCOPE = 'AttributeScopeInconsistency'
ATTRIBUTE_TYPE = 'AttributeTypeIssue'
ATTRIBUTE_UNDEFINED = 'AttributeUndefined'
ATTRIBUTE_VALUE = 'AttributeValueIssue'
DIMENSION_INVALID = 'DimensionInvalidIssue'
EGO_TRACK_BOTH_RAILS = 'EgoTrackBothRails'
EMPTY_FRAMES = 'EmptyFramesIssue'
HORIZON_CROSSED = 'HorizonCrossedIssue'
MISSING_EGO_TRACK = 'MissingEgoTrackIssue'
OBJECT_TYPE_UNDEFINED = 'ObjectTypeUndefined'
RAIL_SIDE = 'RailSide'
SCHEMA = 'SchemaIssue'
SENSOR_ID_UNKNOWN = 'SensorIdUnknown'
SENSOR_TYPE_WRONG = 'SensorTypeWrong'
TRANSITION_IDENTICAL_START_END = 'TransitionIdenticalStartAndEnd'
UNEXPECTED_CLASS = 'UnexpectedClassIssue'
URI_FORMAT = 'UriFormatIssue'
classmethod names() list[str]

Return the string names of all IssueTypes as a list.

raillabel_providerkit.validation.issue_schema module

raillabel_providerkit.validation.validate module

raillabel_providerkit.validation.validate.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.

Module contents

Package for validating raillabel data regarding the format requirements.

class raillabel_providerkit.validation.Issue(type: IssueType, identifiers: IssueIdentifiers | list[str | int], reason: str | None = None)

Bases: object

An error that was found inside the scene.

classmethod deserialize(serialized_issue: dict[str, str | dict[str, str | int] | list[str | int]]) Issue

Deserialize a JSON-compatible dictionary back into an Issue class instance.

Parameters:

serialized_issue (dict[str, str | dict[str, str | int] | list[str | int]]) – The serialized Issue as a JSON-compatible dictionary

Returns:

The deserialized Issue class instance

Return type:

Issue

Raises:

jsonschema.exceptions.ValidationError – If the serialized data does not match the Issue JSONSchema.

identifiers: IssueIdentifiers | list[str | int]
reason: str | None = None
serialize() dict[str, str | dict[str, str | int] | list[str | int]]

Serialize the Issue into a JSON-compatible dictionary.

Returns:

The serialized Issue as a JSON-compatible dictionary

Return type:

dict[str, str | dict[str, str | int] | list[str | int]]

type: IssueType
class raillabel_providerkit.validation.IssueIdentifiers(annotation: UUID | None = None, annotation_type: Literal['Bbox', 'Cuboid', 'Num', 'Poly2d', 'Poly3d', 'Seg3d'] | None = None, attribute: str | None = None, frame: int | None = None, object: UUID | None = None, object_type: str | None = None, sensor: str | None = None)

Bases: object

Information for locating an issue.

annotation: UUID | None = None
annotation_type: Literal['Bbox', 'Cuboid', 'Num', 'Poly2d', 'Poly3d', 'Seg3d'] | None = None
attribute: str | None = None
classmethod deserialize(serialized_identifiers: dict[str, str | int]) IssueIdentifiers

Deserialize a JSON-compatible dictionary back into an IssueIdentifiers class instance.

Parameters:

serialized_identifiers (dict[str, str | int]) – The serialized IssueIdentifiers as a JSON-compatible dictionary

Returns:

The deserialized IssueIdentifiers class instance

Return type:

IssueIdentifiers

Raises:

TypeError – If any of the fields have an unexpected type

frame: int | None = None
object: UUID | None = None
object_type: str | None = None
sensor: str | None = None
serialize() dict[str, str | int]

Serialize the IssueIdentifiers into a JSON-compatible dictionary.

Returns:

The serialized IssueIdentifiers as a JSON-compatible dictionary

Return type:

dict[str, str | int]

class raillabel_providerkit.validation.IssueType(*values)

Bases: Enum

General classification of the issue.

ANNOTATION_SENSOR_MISMATCH = 'AnnotationSensorMismatch'
ATTRIBUTE_MISSING = 'AttributeMissing'
ATTRIBUTE_SCOPE = 'AttributeScopeInconsistency'
ATTRIBUTE_TYPE = 'AttributeTypeIssue'
ATTRIBUTE_UNDEFINED = 'AttributeUndefined'
ATTRIBUTE_VALUE = 'AttributeValueIssue'
DIMENSION_INVALID = 'DimensionInvalidIssue'
EGO_TRACK_BOTH_RAILS = 'EgoTrackBothRails'
EMPTY_FRAMES = 'EmptyFramesIssue'
HORIZON_CROSSED = 'HorizonCrossedIssue'
MISSING_EGO_TRACK = 'MissingEgoTrackIssue'
OBJECT_TYPE_UNDEFINED = 'ObjectTypeUndefined'
RAIL_SIDE = 'RailSide'
SCHEMA = 'SchemaIssue'
SENSOR_ID_UNKNOWN = 'SensorIdUnknown'
SENSOR_TYPE_WRONG = 'SensorTypeWrong'
TRANSITION_IDENTICAL_START_END = 'TransitionIdenticalStartAndEnd'
UNEXPECTED_CLASS = 'UnexpectedClassIssue'
URI_FORMAT = 'UriFormatIssue'
classmethod names() list[str]

Return the string names of all IssueTypes as a list.

raillabel_providerkit.validation.validate_dimensions(scene: Scene) list[Issue]

Validate whether any annotations exceed the predefined bounds.

Parameters:

scene (Scene) – Scene that should be validated.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_ego_track_both_rails(scene: Scene) list[Issue]

Validate that ego track has both left and right rails in center cameras.

This validator checks: 1. That the y-ranges of left and right ego track rails overlap 2. That exactly one left and one right rail exist at the common y position

Parameters:

scene (raillabel.Scene) – Scene that should be validated.

Returns:

List of all ego track rail issues. If an empty list is returned, then there are no errors present.

Return type:

list[Issue]

raillabel_providerkit.validation.validate_empty_frames(scene: Scene) list[Issue]

Validate whether sensors requiring annotations have at least one annotation per frame.

Only validates middle/center cameras and lidar sensors. This matches the behavior of the legacy annotation-checks tool.

Parameters:

scene (raillabel.Scene) – Scene that should be validated.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_horizon(scene: Scene, horizon_tolerance_percent: float = 10.0) list[Issue]

Validate whether all track/transition annotations are below the horizon.

This validation only applies to track and transition object types. Other object types are not checked against the horizon line.

The horizon is calculated based on each camera’s pitch angle (tilt), derived from the extrinsics rotation matrix. This approach is robust across different calibration conventions (OSDAR23, OSDAR26, etc.).

Parameters:
  • scene (raillabel.Scene) – Scene that should be validated.

  • horizon_tolerance_percent (float, optional) – Tolerance buffer as percentage of the horizon position from the top of the image. Higher values move the horizon line up (smaller Y), making the validation more permissive. For example, 10.0 means the horizon is moved up by 10% of its distance from the top. Default is 10.0.

Returns:

List of all horizon crossing errors in the scene (only for track/transition annotations). If an empty list is returned, then there are no errors present.

Return type:

list[Issue]

raillabel_providerkit.validation.validate_missing_ego_track(scene: Scene) list[Issue]

Validate whether all middle cameras and lidar have ego track annotations.

This matches the behavior of the legacy annotation-checks tool which uses both EgoTrackBothRailsValidator (for cameras) and EgoTrackLidarValidator (for lidar).

Parameters:

scene (raillabel.Scene) – Scene that should be validated.

Returns:

List of all missing ego track errors in the scene. If an empty list is returned, then there are no errors present.

Return type:

list[Issue]

raillabel_providerkit.validation.validate_ontology(scene: Scene, ontology_input: dict | Path) list[Issue]

Validate a scene based on the classes and attributes.

Parameters:
  • scene (raillabel.Scene) – The scene containing the annotations.

  • ontology_input (dict or Path) – Ontology YAML-data or file containing a information about all classes and their attributes. The ontology must adhere to the ontology_schema. If a path is provided, the file is loaded as a YAML.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_rail_side(scene: Scene) list[Issue]

Validate whether all tracks have <= one left and right rail, and that they have correct order.

Parameters:

scene (raillabel.Scene) – Scene, that should be validated.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_schema(data: dict) list[Issue]

Validate a scene for adherence to the raillabel schema.

Parameters:

data (dict) – _description_

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_sensors(scene: Scene) list[Issue]

Validate whether whether all sensors have supported names and have the correct type.

Parameters:

scene (raillabel.Scene) – Scene that should be validated.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_transition(scene: Scene) list[Issue]

Validate whether transition annotations have different start and end tracks.

This matches the behavior of the legacy annotation-checks TransitionValidator.

Parameters:

scene (raillabel.Scene) – Scene that should be validated.

Returns:

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

Return type:

list[Issue]

raillabel_providerkit.validation.validate_uris(scene: Scene) list[Issue]

Validate whether all uri fields in a scene comply with the schema.

Parameters:

scene (Scene) – Scene that should be validated.

Returns:

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

Return type:

list[Issue]