Skip to content

schema

Name of schemas


SchemaName

Bases: StrEnum

An enum to represent schema filenames.

Attributes:

  • ATTRIBUTE

    Property of an instance that can change while the category remains the same.

  • CALIBRATED_SENSOR

    Definition of a particular sensor as calibrated on a vehicle.

  • CATEGORY

    Object categories.

  • EGO_POSE

    Ego vehicle pose at at particular timestamp.

  • INSTANCE

    An object instance.

  • LOG

    Information about the log from which the data aws extracted.

  • MAP

    Map data that is stored as binary semantic masks from a top-down view.

  • SAMPLE

    A sample is an annotated keyframe at specific Hz.

  • SAMPLE_ANNOTATION

    A bounding box defining the position of an object seen in a sample.

  • SAMPLE_DATA

    A sensor data e.g. image, pointcloud or radar return.

  • SCENE

    A scene is a specific long sequence of consecutive frames extracted from a log.

  • SENSOR

    A specific sensor type.

  • VISIBILITY

    The visibility of instance is the fraction of annotation visible in all images.

  • OBJECT_ANN (optional) –

    The annotation of a foreground object in an image.

  • SURFACE_ANN (optional) –

    The annotation of a background object in an image.

  • KEYPOINT (optional) –

    The annotation of pose keypoints of an object in an image.

filename property

filename: str

Return the annotation json filename.

Returns:

  • str

    Annotation json filename.

is_optional

is_optional() -> bool

Indicates if this schema name is optional.

Returns:

  • bool

    Return True if this schema is optional.

Table of schemas


SchemaBase dataclass

SchemaBase(token: str)

Abstract base dataclass of schema tables.

shortcuts staticmethod

shortcuts() -> tuple[str, ...] | None

Return a sequence of shortcut field names.

Returns:

  • tuple[str, ...] | None

    Returns None if there is no shortcut. Otherwise, returns sequence of shortcut field names.

from_json classmethod

from_json(filepath: str) -> list[Self]

Construct dataclass from json file.

Parameters:

  • filepath (str) –

    Filepath to json.

Returns:

  • list[Self]

    List of instantiated schema dataclasses.

from_dict abstractmethod classmethod

from_dict(data: dict[str, Any]) -> Self

Construct dataclass from dict.

Parameters:

  • data (dict[str, Any]) –

    Dict data.

Returns:

  • Self

    Instantiated schema dataclass.


Attribute dataclass

Bases: SchemaBase

A dataclass to represent schema table of attribute.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • name (str) –

    Attribute name.

  • description (str) –

    Attribute description.

CalibratedSensor dataclass

Bases: SchemaBase

A dataclass to represent schema table of calibrated_sensor.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sensor_token (str) –

    Foreign key pointing to the sensor type.

  • translation (TranslationType) –

    Coordinates system origin given as [x, y, z] in [m].

  • rotation (RotationType) –

    Coordinates system orientation given as quaternion [w, x, y, z].

  • camera_intrinsic (CamIntrinsicType) –

    3x3 camera intrinsic matrix. Empty for sensors that are not cameras.

  • camera_distortion (CamDistortionType) –

    Camera distortion array. Empty for sensors that are not cameras.

Category dataclass

Bases: SchemaBase

A dataclass to represent schema table of category.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • name (str) –

    Category name.

  • description (str) –

    Category description.

EgoPose dataclass

Bases: SchemaBase

A dataclass to represent schema table of ego_pose.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • translation (TranslationType) –

    Coordinate system origin given as [x, y, z] in [m].

  • rotation (RotationType) –

    Coordinate system orientation given as quaternion [w, x, y, z].

  • timestamp (int) –

    Unix time stamp.

Instance dataclass

Bases: SchemaBase

A dataclass to represent schema table of instance.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • category_token (str) –

    Foreign key pointing to the object category.

  • instance_name (str) –

    Dataset name and instance ID defined in annotation tool.

  • nbr_annotations (int) –

    Number of annotations of this instance.

  • first_annotation_token (str) –

    Foreign key pointing to the first annotation of this instance.

  • last_annotation_token (str) –

    Foreign key pointing to the last annotation of this instance.

Keypoint dataclass

Bases: SchemaBase

A dataclass to represent schema table of keypoint.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sample_data_token (str) –

    Foreign key pointing to the sample data, which must be a keyframe image.

  • instance_token (str) –

    Foreign key pointing to the instance.

  • category_tokens (list[str]) –

    Foreign key pointing to keypoints categories.

  • keypoints (KeypointType) –

    Annotated keypoints. Given as a list of [x, y].

  • num_keypoints (int) –

    The number of keypoints to be annotated.

Log dataclass

Bases: SchemaBase

A dataclass to represent schema table of log.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • logfile (str) –

    Log file name.

  • vehicle (str) –

    Vehicle name.

  • data_captured (str) –

    Date of the data was captured (YYYY-MM-DD-HH-mm-ss).

  • location (str) –

    Area where log was captured.

Map dataclass

Bases: SchemaBase

A dataclass to represent schema table of map.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • log_tokens (str) –

    Foreign keys pointing the log tokens.

  • category (str) –

    Map category.

  • filename (str) –

    Relative path to the file with the map mask.

RLEMask dataclass

A dataclass to represent segmentation mask compressed by RLE.

Attributes:

  • size (list[int, int]) –

    Size of image ordering (width, height).

  • counts (str) –

    RLE compressed mask data.

decode

decode()

Decode segmentation mask.

Returns:

  • NDArrayU8

    Decoded mask in shape of (H, W).

ObjectAnn dataclass

Bases: SchemaBase

A dataclass to represent schema table of object_ann.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sample_data_token (str) –

    Foreign key pointing to the sample data, which must be a keyframe image.

  • instance_token (str) –

    Foreign key pointing to the instance.

  • category_token (str) –

    Foreign key pointing to the object category.

  • attribute_tokens (list[str]) –

    Foreign keys. List of attributes for this annotation.

  • bbox (RoiType) –

    Annotated bounding box. Given as [xmin, ymin, xmax, ymax].

  • mask (RLEMask) –

    Instance mask using the COCO format compressed by RLE.

width property

width

Return the width of the bounding box.

Returns:

  • int

    Bounding box width in pixel.

height property

height

Return the height of the bounding box.

Returns:

  • int

    Bounding box height in pixel.

Sample dataclass

Bases: SchemaBase

A dataclass to represent schema table of sample.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • timestamp (int) –

    Unix time stamp.

  • scene_token (str) –

    Foreign key pointing to the scene.

  • next (str) –

    Foreign key pointing the sample that follows this in time. Empty if end of scene.

  • prev (str) –

    Foreign key pointing the sample that precedes this in time. Empty if start of scene.

Shortcuts:
data (dict[str, str]): Sensor channel and its token.
    This should be set after instantiated.
ann_3ds (list[str]): List of foreign keys pointing the sample annotations.
    This should be set after instantiated.
ann_2ds (list[str]): List of foreign keys pointing the object annotations.
    This should be set after instantiated.
surface_anns (list[str]): List of foreign keys pointing the surface annotations.
    This should be set after instantiated.

SampleAnnotation dataclass

Bases: SchemaBase

A dataclass to represent schema table of sample_annotation.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sample_token (str) –

    Foreign key pointing the sample.

  • instance_token (str) –

    Foreign key pointing the object instance.

  • attribute_tokens (list[str]) –

    Foreign keys. List of attributes for this annotation.

  • visibility_token (str) –

    Foreign key pointing the object visibility.

  • translation (TranslationType) –

    Bounding box location given as [x, y, z] in [m].

  • size (SizeType) –

    Bounding box size given as [width, length, height] in [m].

  • rotation (RotationType) –

    Bounding box orientation given as quaternion [w, x, y, z].

  • num_lidar_pts (int) –

    Number of lidar points in this box.

  • num_radar_pts (int) –

    Number of radar points in this box.

  • next (str) –

    Foreign key pointing the annotation that follows this in time. Empty if this is the last annotation for this object.

  • prev (str) –

    Foreign key pointing the annotation that precedes this in time. Empty if this the first annotation for this object.

  • velocity (VelocityType | None) –

    Bounding box velocity given as [vx, vy, vz] in [m/s].

  • acceleration (AccelerationType | None) –

    Bonding box acceleration given as [ax, ay, av] in [m/s^2].

Shortcuts:
category_name (str): Category name. This should be set after instantiated.

SampleData dataclass

Bases: SchemaBase

A class to represent schema table of sample_data.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sample_token (str) –

    Foreign key pointing the sample.

  • ego_pose_token (str) –

    Foreign key pointing the ego_pose.

  • calibrated_sensor_token (str) –

    Foreign key pointing the calibrated_sensor.

  • filename (str) –

    Relative path to data-blob on disk.

  • fileformat (FileFormat) –

    Data file format.

  • width (int) –

    If the sample data is an image, this is the image width in [px].

  • height (int) –

    If the sample data is an image, this is the image height in [px].

  • timestamp (int) –

    Unix time stamp.

  • is_key_frame (bool) –

    True if sample_data is part of key frame else, False.

  • next (str) –

    Foreign key pointing the sample_data that follows this in time. Empty if end of scene.

  • prev (str) –

    Foreign key pointing the sample_data that precedes this in time. Empty if start of scene.

  • is_valid (bool) –

    True if this data is valid, else False. Invalid data should be ignored.

Shortcuts:
modality (SensorModality): Sensor modality. This should be set after instantiated.
channel (str): Sensor channel. This should be set after instantiated.

Scene dataclass

Bases: SchemaBase

A dataclass to represent schema table of scene.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • name (str) –

    Short string identifier.

  • description (str) –

    Longer description for the scene.

  • log_token (str) –

    Foreign key pointing to log from where the data was extracted.

  • nbr_samples (int) –

    Number of samples in the scene.

  • first_sample_token (str) –

    Foreign key pointing to the first sample in scene.

  • last_sample_token (str) –

    Foreign key pointing to the last sample in scene.

Sensor dataclass

Bases: SchemaBase

A dataclass to represent schema table of sensor.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • channel (str) –

    Sensor channel name.

  • modality (SensorModality) –

    Sensor modality.

Shortcuts:
first_sd_token (str): The first sample data token corresponding to its sensor channel.

SurfaceAnn dataclass

Bases: SchemaBase

A dataclass to represent schema table of surface_ann.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • sample_data_token (str) –

    Foreign key pointing to the sample data, which must be a keyframe image.

  • category_token (str) –

    Foreign key pointing to the surface category.

  • mask (RLEMask) –

    Segmentation mask using the COCO format compressed by RLE.

bbox property

bbox

Return a bounding box corners calculated from polygon vertices.

Returns:

  • RoiType

    Given as [xmin, ymin, xmax, ymax].

Visibility dataclass

Bases: SchemaBase

A dataclass to represent schema table of visibility.json.

Attributes:

  • token (str) –

    Unique record identifier.

  • level (VisibilityLevel) –

    Visibility level.

  • description (str) –

    Description of visibility level.

Other items constructing schema table


FileFormat

Bases: StrEnum

An enum to represent file formats.

Attributes:

  • JPG

    JPG format for image data.

  • PNG

    PNG format for image data.

  • PCD

    PCD format for pointcloud data.

  • BIN

    BIN format.

  • PCDBIN

    PCD.BIN format for pointcloud data.

is_member staticmethod

is_member(item)

Indicate whether the input item is the one of members of FileFormat.

Parameters:

  • item (str) –

    Any file format name.

Returns:

  • bool

    Return True if the item is included.

values staticmethod

values()

Return a list of values of members.

Returns:

  • list[str]

    List of values.

as_ext

as_ext()

Return the value as file extension.

Returns:

  • str

    File extension.

SensorModality

Bases: StrEnum

An enum to represent sensor modalities.

Attributes:

  • LIDAR

    Lidar sensor.

  • CAMERA

    Camera sensor.

  • RADAR

    Radar sensor.

VisibilityLevel

Bases: StrEnum

An enum to represent visibility levels.

Attributes:

  • FULL

    No occlusion for the object.

  • MOST

    Object is occluded, but by less than 50%.

  • PARTIAL

    Object is occluded, but by more than 50%.

  • NONE

    Object is 90-100% occluded and no points/pixels are visible in the label.

  • UNAVAILABLE

    Visibility level is not specified.

from_value classmethod

from_value(level)

Load member from its value.

Schema registry


build_schema

build_schema(name: str | SchemaName, filepath: str) -> list[SchemaTable]

Build schema dataclass from json file path.

Parameters:

  • name (str | SchemaName) –

    Name of schema table.

  • filepath (str) –

    Path to json file.

Returns:

  • list[SchemaTable]

    List of schema dataclasses.

SCHEMAS module-attribute

SCHEMAS = SchemaRegistry()

SchemaRegistry

SchemaRegistry()

A manager class to register schema tables.

build_from_json

build_from_json(key: str | SchemaName, filepath: str) -> list[SchemaTable]

Build schema dataclass from json.

Parameters:

  • key (str) –

    Name of schema field.

  • filepath (str) –

    Path to schema json file.

Returns:

  • list[SchemaTable]

    Instantiated dataclass.

Serialize schema


serialize_schemas

serialize_schemas(data: list[SchemaTable]) -> list[dict]

Serialize a list of schema dataclasses into list of dict.

Parameters:

  • data (list[SchemaTable]) –

    List of schema dataclasses.

Returns:

  • list[dict]

    Serialized list of dict data.

serialize_schema

serialize_schema(data: SchemaTable) -> dict

Serialize a schema dataclass into dict.

Parameters:

  • data (SchemaTable) –

    Schema dataclass.

Returns:

  • dict

    Serialized dict data.